Why can't you install a GFCI in a box that has more than 4 wires (not including ground)?

Question: I installed a GFCI receptacle yesterday, the instructions were saying that if you see more than 4 wires in the box (excluding the ground) call an electrician.
In my case everything you see to the right of the brown dotted line was connected to one box (4x4)
Comment: Because writing instructions for up to 4 wires is easy(ish) - with certain assumptions made about the wiring. Once you have more than 4 wires you really need to know which ones go where and do what. So the manufacturers include the instructions for up to 4 wires, but (probably to reduce their potential liability) tell you to call a pro for anything more complicated.
Comment: Can you post photos of the inside of the box please?
Comment: It is closed and the cover is on, I am not going to open it again soon.
Comment: ok if it is only that then it is not a problem, it is working as expected for me. That box was a little bit "crowded" but with proper wiring everything fitted in in the end. I made sure all the hot wires were also covered by tape (I run two rounds of tape around the switch and around the GFCI
Comment: @minime do the lights and receptacles in the garage turn off when you turn off your indoor switch light? I ask as they probably don't but may, and if everything is not controlled by that switch , you can see how easy it would be to make a wiring mistake.
Comment: The do, when I turn off the indoor switch everything is off. It I turn on that switch and I turn off the garage switch then the garage lights are off while the GFCI still has power (as intended and confirmed by the green light on the receptacle)
Comment: I also feel like "box fill" has something to do with it.  Four wires and a ground and the larger than normal receptacle will hit the fill limit of a single gang box easily.
Comment: That is very true, it was a little bit tight and partially because I had longer grounds but it is difficult for a DIY to cut them to the minimum size when you have one incoming cable, two gangs occupied and two outgoing cables. I wish I bought a deeper box but I am not sure if there was one. There were wider boxes but I could not figure out how to install the GFCI and the light switch there. The wall plate would have been a problem too
Comment: Really the mfg has no idea what size box is being used, changing a device if the fill was legal to start with it will be after unless some unusual or type of device.
Comment: Basically, because when you're wiring a GFCI you need to know what you're doing.
Comment: See also https://diy.stackexchange.com/questions/183630/2-sets-of-line-wires?rq=1
Answer: Instructions are obtuse because of UL
This has to do with the device's UL listing.  UL only approves devices for certain applications; i.e. you can't use an Alumiconn to splice 9600V wiring. Two things assure you stay within those applications:  First NEC 110.3(B) which requires you obey the labeling and instructions, and second, UL also approves the labeling and instructions as part of the listing.  That is because, generally, they only test for conditions described in the instructions (e.g. they don't test Alumiconn for 9600V splices).  Anyway, if you wonder why some instructions are so stilted and weird, that is why.
When a manufacturer writes instructions likely to be read by amateurs, UL gives it extra scrutiny.  It is UL who is imposing the "See electrician for >4 wires" issue.  You have to hook up the two LINE terminals or the device won't function.  With only 2 additional wires, UL feels comfortable with the instructions.  >4, there become several wrong/dangerous ways to hook it up.
Just use LINE.  Leave LOAD alone.
Anyway, for you, it is simplicity itself.  Everything goes onto LINE.  Don't even remove the warning tape from the LOAD terminals.  So you would just pigtail.
Do not use the LOAD terminals at all unless you have a specific reason to do so, and only for the pairs of wires where that reason exists.  The instructions will say something else; they want you to ignorantly protect parts of your circuit without realizing you are doing so, and because of the side-effects, that's something I do not agree with.
Why not use LOAD for everything? Well, you're perfectly allowed to; and you're advised to by the instructions.  That will place everything downline into the GFCI protected zone.  That seems oh, so clever: Free protection! And that is the purpose of having LOAD terminals!  However, this has a dark side, if those downline loads don't need GFCI protection.  Any trivial leakage from those things will stack i.e. cumulate, increasing your risk of nuisance trips.  Nuisance trips drive people crazy.  Do people do a laborious bug hunt on each leg of the downline that wasn't even part of the project in the first place, to suss out every last dirty contact or NM wire that's getting wet, or stick isolation transformers on their refrigerators?  No, they don't; they rip out the GFCI.
So "GFCI everything" is a grand theory, but not something you can really live with.  UL doesn't care about that. They say "you should do the bug hunt".  UL can come and do the bug hunt, IMO.
What is a good idea to not protect?

Grounded hardwired loads, esp. lighting where dangerous power tools operate (e.g. curling irons)
Any downline outlet which has its own GFCI protection
Refrigerators that are cord-and-plug connected (post NEC 2014 you'll need to get a variance if the fridge is in a location where all receps need GFCI)
Safety equipment of any kind (including refrigerators).  It won't do to have an emergency fire pump trip a GFCI the moment it starts; the purpose of the gadget is to protect from fire, not electrical shocks.
Comment: @MiniMe In a nutshell: other receptacles need GFCI (and then Load means you can use a non-GFCI receptacle and still be protected) but lights/fans/other built-in items generally do **not** need GFCI. Using Load for lights means if your GFCI trips you are in the dark. If you use Line then the lights stay on. Which is important if the trip was due to a power tool or hair dryer around wet areas...
Comment: Harper:  I tend to agree with sentiments...in many cases GFCI protection creates more problems than it solves...you'd think we don't have ground wires anymore.  But this gets worse with the NEC 2020 code:  Just about EVERYTHING will require GFCI including 240 v appliances (Ranges, dryers, water heaters!!!!, furnaces, etc.)
Comment: Can you please detail on this? I did use the load to go from the GFCI to the switch and from there further to the lights ... they indeed recommend that you use the load to feed anything downstream. If I have problems with the insurance I will show them the instructions :-) ..I can't point them to this post :-))
Comment: At the same time, a GFCI in a bathroom might *NEED* the load terminals to protect (eg) a light over the shower, etc - it's equally easy for Joe handyman to get lost among the wires and improperly *remove* protection from parts of the circuit that should have had it.  The bottom line is, the warning is there because OP probably should consult an electrician if they're even remotely unsure about which wires go where.
Answer: I have seen those instructions, I thought it was funny at first but after thinking of the number of times DIY folks get line and load mixes up with just 4 wires and all the rat's nests I have repaired over the years it may make sense for those that do not understand what they are doing.
The line terminals connect to the feeder from the panel normally black on brass and white on silver  then a receptacle that is fed from this would be on load same color combinations.
Where things can get sketchy if there happened to be 1 additional red wire for a switched outlet as GFCI receptacles do not have a tab to break the top receptacle feed from the bottom one (if there is not a wired light in the room additional work needs to be done to maintain a switched receptacle as code has required for decades if no wired light fixture)
Other things like multi wire branch circuits can be there with an additional wire normally red again , this circuit has 240v between the red and the black and is a way to have an additional circuit while running less wires (saves $) .
Last as you have multiple feeds to other circuits, so it is not as easy as this goes there and the reason the MFG suggests a pro this way if you hook it up wrong the mfg is not liable for damages. 4 wires can be messed up but as you can see it may not work but with a multi wire branch circuit you could be shorting the 2 legs of your service together if done wrong and that is about the worst thing that can be done especially if you find yourself in the circuit some way.
Comment: Totally agree... a DIY nightmare .. +
Comment: In my case I connected the wires coming from outside to the GFCI and then I took the hot wire of the load and I connected that to the switch. The other end of the switch then was tied together with the blacks of the two lights. The white of the GFCI load was tied together with the whites of the lights, The ground of  outside wire was connected to the wire of the box and then all the grounds in the box (GFCI and the two lights )  were connected to the ground of the box ..so as long as, after the GFCI you do not mix the colors it's OK.
Agree the MFG can't provide instructions 4 all situations
Comment: above "connected to the wire of the box" wanted to be "connected to the ground of the box"


Can't import local module

Question: I installed an application in the /opt directory and added its root to the PATH (for all users who want to use it). Now, when I invoke the master script from my user, it works fine, but other users report the same error:
user@server:~$ ragout.py -h
Traceback (most recent call last):
  File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
    from ragout.main import main
  File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
    from ragout.main import main
ImportError: No module named main

Here is the master script:
#!/usr/bin/env python2.7

#(c) 2013-2014 by Authors
#This file is a part of Ragout program.
#Released under the BSD license (see LICENSE file)

"""
This script does all the necessary preparations
and invokes Ragout
"""

import os
import sys

LIB_DIR = "lib"

#Check Python version
if sys.version_info[:2] != (2, 7):
    print("Error: Ragout requires Python version 2.7 ({0}.{1} detected)."
          .format(sys.version_info[0], sys.version_info[1]))
    sys.exit(-1)

#Setting executable paths
ragout_root = os.path.dirname(os.path.realpath(__file__))
lib_absolute = os.path.join(ragout_root, LIB_DIR)
sys.path.insert(0, lib_absolute)
sys.path.insert(0, ragout_root)
os.environ["PATH"] = lib_absolute + os.pathsep + os.environ["PATH"]

#Ragout entry point
from ragout.main import main
sys.exit(main())

I figured the script could face some problems expanding ragout_root and lib_absolute, so I added print(ragout_root, lib_absolute) just before the from ragout.main import main to see, what's happening. Now, when I run the app from my user, I get this:
me@server:~$ ragout.py -h
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
usage: ragout.py [-h] [-o output_dir] [-s {sibelia,maf,hal}] [--refine]
                 [--solid-scaffolds] [--overwrite] [--repeats] [--debug]
                 [-t THREADS] [--version]
                 recipe_file
...

and the users get this
user@server:~$ ragout.py -h
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
('/opt/ragout-2.0-linux-x86_64', '/opt/ragout-2.0-linux-x86_64/lib')
Traceback (most recent call last):
  File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
    from ragout.main import main
  File "/opt/ragout-2.0-linux-x86_64/ragout.py", line 33, in <module>
    from ragout.main import main
ImportError: No module named main

For whatever reason it prints twice and – although the paths are correct – it still can't import from the local module. Any ideas?
Comment: The name of the script `ragout.py` clashes with the name of the `regout` package. You just need to rename the script.
Comment: I think `from ragout.main import main` tries to import `main` from your `ragout.py` which is not defined there. It prints the line twice because basically you built an [infinite import loop](http://stackoverflow.com/q/3558842/3005167) but Python is too smart to get locked up.
Comment: @kazemakase then why does it work for my user?
Comment: @KlausD. Yeah, I've tried that already to no avail.
Comment: @kazemakase and I've tried renaming `ragout.py`, too. It seems to make no difference at all.
Comment: @EliKorvigo so it works on your machine but not on your users'? That's damn hard to debug :) Try to print `sys.path` on both machines. If `"."` or `""` is in the path of only one of them this may be the reason why the script tries to import itself.
Comment: Nevermind, you put the path to ragout in front anyway.
Comment: @kazemakase it is the same machine and the same installation just different users.
Comment: Do the other users have the correct permissions to see the location?
Comment: What are the directory contents ?
Answer: I think this is a permissions issue. See this Stack Overflow question where the user reports a very similar issue.

You created the location, therefore you have permissions for it and
can import it.
The other users do not have permission and cannot import from a folder they can't read.

Solution: make sure the all appropriate users are in a user group with at least read permission to the folder.
Comment: Yes, you are right. The users have rights to access the root directory containing `ragout.py` itself, but not the subdirectories.

Can't import local module


How to determine which assembly a specific class belongs to?

Question: Often i have a problem that I need to determine which assebmly to include
into my project in order to use specific class. For instance I want to you
TypeInfo class. MSDN does not say it belongs to. Actually I am not even been able to find
TypeInfo class using MSDN document explorer search. All the results relate to some other stuff. For instance first result is about System.Runtime.Remoting.
Also MSDN says - assembly mscorlib. In the components page of Add Reference dialog box
i can see mscorlib but also fully qualified names like System.RunTime.Serialization
What is the difference?
Comment: TypeInfo isn't a documented framework class. What namespace do you have for it?
Comment: Oh I am sorry. I needed class Type, not TypeInfo :(((
But anyway thanks for the answer
Answer: MSDN absolutely does say which assembly it belongs to, at the top of the page, as well as the namespace. I'm not quite sure which TypeInfo class you're talking about in mscorlib though - this one is in Microsoft.Web.Management.DatabaseManager.dll. Did you mean PropertyInfo or something similar?
Things like System.Runtime.Serialization are still assemblies, but also namespaces. Many types live in an assembly with the same name as their namespace, but that's convention rather than a rule. MSDN tells you both.
For example, PropertyInfo is in the mscorlib assembly, but the System.Reflection namespace  - as specified in the page linked earlier.


Is there a hotkey equivalent to exit command?

Question: I have to use ssh on regular basis and I would like to exit each terminal before closing the window. This means I have to execute exit multiple times. And I was wondering if there is a hotkey for that? I know Ctrl + Shift + q closes the terminal but that's not exit.
Comment: Awesome, thanks. If it was a post I could flag it as an answer.
Answer: You can use Ctrl + d -- End of Transmission.


How to Remove Cpvc from copper shower valve?

Question:
I discovered a slow leak in the house I purchased which was causing all sorts of moisture related issues. (pretty sure the previous owners knew about it cause they had just installed new carpet and just happened to leave a water key, but that's another story...)
After cutting open some access to the shower valve, I quickly discovered the source of the leak was where the male Cpvc adapter fit into what appears to be a female copper adapter that has been sweated to the shower valve.
Upon trying to remove the existing cpvc adapter, it snapped and began deteriorating on me, now I am stuck with a valve that has the threading of the pvc adapter still in the copper adapter with no obvious way to remove it to replace it with another.
(it was difficult to capture a picture of the plastic inside the copper adapter as there is a wall stud the runs parallel to the piping, but it is the right hand side of the valve above with nothing attached to it.)
What is the best course of action to resolve this? Is it possible to find a way to destroy/remove the remaining plastic without messing up the copper threads? Or will it be necessary to remove the entire shower assembly and go from there by replacing the metal adapter or possibly the whole assembly if it is unfeasible to "unsweat" and replace the copper adapter?
Comment: Where are these copper threads you're referring to?  Also, I don't like the way the vertical CPVC+Cu pipes are run on the edge of the stud (appears to against the back the shower wall).
Comment: Have you considered a shark bite fitting? Just a thought.
Comment: @CalvinNHobbes A sharkbite, while convenient for joining the two CPVC pipes running vertically here would not have resolved the stuck threads inside of the metal fitting.
Comment: @stevesh the plastic stuck in the metal threads cannot be seen in the picture but they are inside of the fitting that has been sweated to the shower valve. That fitting is facing right towards the vertical CPVC piping
Answer: Generically, an extractor of the appropriate size.
"Pipe thread extractor" or "internal pipe wrench" yield results in a search.
Comment: Pipe thread extractor did the trick


Nonobvious examples of metric spaces that do not work like $\mathbb{R}^n$

Question: This week, I come to the end of the first year analysis, and suffer from a "crisis of motivation."  With this question, I want to chase away my thought, "Why is it important to study the general properties of metric spaces? Is every good example just a subset of $\mathbb{R}^n$?"
I will explain.  During many proofs, I visualize something like $\mathbb{R}^2$.  The professor always draws these pictures:

This is good for many theorems, since much of the analysis is motivate by questions about $\mathbb{R}^n$.  But my mental picture is now only $\mathbb{R}^n$. For appreciate the study of metric spaces in full generality, and for intuition, I request more useful examples of metric spaces that are significantly different from $\mathbb{R}^n$, and are not contain in $\mathbb{R}^n$.
Here, I say "useful" to mean that the example "could naturally arise in another context", in mathematics or an application.  It is frustrate when I ask why some property does not hold in general, and someone tells me consider the discrete metric.  Yes, it is true, and it is easy to see, but the discrete metric is stupid.  Does my property fail in any metric space that someone would care about?
In other words, I have the following taxonomy of metric spaces:

$\mathbb{R}^n$ and the subsets
degenerate examples like the discrete metric
contrived examples that I would not see except in analysis (I mean if they are only exist to be pathological, this is where I think to place the Cantor set)

I want to expand this taxonomy, so that when I hear the new definition or theorem, I can compare to this collection of good examples.  I know there must be examples with intricate and intuitive interpretations in statistics, science, and engineering.

Which metric spaces are not in my mental taxonomy?  In general, what are the useful, non-obvious metric spaces that a student should keep in his mind when learning analysis?

To me, the ideal answer includes the description of the metric space, what properties it has to be unique and different, some consequences of the properties that make different from my examples, and (if not obvious) where I could find the metric space in practice.
One last thing is that I am looking specifically for the examples which are different as metric spaces, so no equivalence to $\mathbb{R}^n$ or any of the subsets or my other list items.  I mean isometry with equivalence, I think, but maybe to homeomorphism, I am not sure how I make the best cut.  I am just unsatisfy for spaces that look too much like what I could build in $\mathbb{R}^n$ and use in practice.
Comment: How about function spaces such as the $L^p$ spaces? They might be "examples that you would not see except in analysis", but they are extremely important, not contrived by any means. There are also the corresponding sequence spaces $l^p$.
Comment: One that I find fun to think about is the Hausdorff metric on the set of compact subsets of $\mathbb{R}^n$. An expanding ball centered on a point, or compact set, is the set itself dilating. This metric space is important in the context of fractals.
Comment: Speaking of the discrete topology, here's an interesting theorem: a space under the discrete topology is homeomorphic to a subset of $\Bbb R^n$ if and only if it is countable.
Comment: @Bungo Maybe you can write some about how to see these, I have heard about but do not know a lot how they work. (I think this question has a few answers, but I hesitate to make big-list so that it will not be an opinion.)
Comment: Ok, I added an answer, hopefully you'll find it interesting.
Comment: @RossPure Can you explain "the set itself dilating"?  I see $\epsilon$ gets bigger we get the points around and the compact sets, but I am confuse on how to see the set is dilate, do you mean take the union is still compact?
Answer: Nice question. I'm not sure that this will be exactly what you want, but let's go for it: consider $X = \{A,B,C,D\}$, and define $d: X \times X \to \Bbb R$ putting $d(p,p) = 0$ for all $p \in X$, $d(p,q) = d(q,p)$ for all $p,q \in X$, and:
$$d(A,B) = d(A,C) = d(B,C) = 2, \qquad d(A,D) = d(B,D) = d(C,D) = 1.$$
Here, $1$ and $2$ are for simplicity (note: $1 < 2$). Here's a picture:

I like to think that this little space is useful for convincing myself that a result I'm seeing for the first time is true.
Comment: By the way, this is a specific case of [neuguy's example](http://math.stackexchange.com/a/1064408/856) of distance on a graph, in this case a [star graph](http://en.wikipedia.org/wiki/Star_%28graph_theory%29) with three leaves.
Comment: I do like this little example very much :)
Answer: Here is one that comes up pretty frequently. Consider a graph $(V,E)$ where $V$ is the set of vertices and $E$ the set of edges. For two vertices $v,w\in V$ define
$$
d(v,w) = \text{length of shortest path between}~v~\text{and}~w.
$$
You can check this is a metric fairly easily. It has applications in discrete mathematics (where you may want to use metric space properties to study a graph), which probably isn't surprising. What may surprise you is that it also has applications in group theory: one can represent a group using a graph (the Cayley graph), and then this metric defines what is called the word metric on the graph. This is one of the topics one might study in geometric group theory.
Comment: This is very good, I think it is qualitate from a lot of the other.  What are the metric properties for this metric (like compact and open sets)?  Is there a page with the list?
Comment: The metric topology coincides with the discrete topology in this case, so topological questions typically aren't very interesting. The interesting questions are how the metric interacts with actions on the group. This lets you study the group via its quasi-isometries, or as a dynamical system, etc.
Comment: I see, that is still very cool.
Comment: @SamuelHandwich: The metric can be extended to the graph itself, by requiring that each edge $E$ be isometric to the unit interval $[0,1]$. These examples are extremely important in group theory where they fall under the nomenclature of the "Cayley graph" of a group http://en.wikipedia.org/wiki/Cayley_graph. These Cayley graphs are the foundation of an entire branch of mathematics known as "geometric group theory" http://en.wikipedia.org/wiki/Geometric_group_theory.
Comment: Tiny nitpick: the graph must be connected for $d$ to be well-defined.
Answer: I think completely  ruling out subsets of $\,\mathbb{R}^n$ misses the point.
Suppose you have a curved surface (for definiteness, sitting in 3-space). If you want to stay inside it, as we do when considering large distances here on earth, we don't use the ambient space metric, but rather the arclength of the shortest path between 2 points, called the geodesic. This metric space can be very different from the ambient space (for instance, the sphere is compact).
Also, the reason your professor's drawing is so useful is because that's precisely the idea metric spaces try to capture: they are sets where we have tools to filter points with balls of arbitrary length. Once we identify a problem can be phrased in the language of metric spaces, our experience with these drawings gives us instant intuition, and enables us to ask the right questions. In abstract places like function spaces, it's this kind of "ball reasoning" that lets us produce beautiful theorems like the Stone-Weierstrass Theorem , even when it might difficult to visualize what ball of functions looks like.
Comment: +1 for "that's precisely the idea metric spaces try to capture"
Comment: Years later, I find I finally understand this comment. Thanks again.
Answer: One important set of spaces that are fundamental to analysis are the $L^p$ spaces. For any real number $p \geq 1$, we define $L^p$ to be the set of all (say real-valued) functions $f$ such that
$$\int |f(x)|^p dx < \infty$$
where the integral is taken over the domain of interest, for example $\mathbb{R}$.
For a function $f \in L^p$, we define the $L^p$ norm of $f$ to be
$$\|f\|_p = \left(\int |f(x)|^p dx\right)^{1/p}$$
and if $f,g \in L^p$, we define the metric (distance) between $f$ and $g$ to be
$$d_p(f,g) = \|f - g\|_p = \left(\int |f(x) - g(x)|^p dx\right)^{1/p}$$
It turns out that $d_p$ satisfies the triangle inequality, which is usually called Minkowski's inequality in this context. (Note that the triangle inequality fails for $p < 1$, which is why we restrict our attention to $p \geq 1$.) Also, clearly $d_p(f,g) = d_p(g,f)$ and $d_p(f,g) \geq 0$ for all $f,g \in L^p$.
One subtle point is that $d_p$ is not quite a metric, because it's possible to have $d_p(f,g) = 0$ for two different functions $f$ and $g$. However, if $d_p(f,g) = 0$, then $f$ and $g$ are "almost" equal (we say that they are equal almost everywhere, or equal except on a set of measure zero). So with the understanding that we don't make a distinction between functions that are almost equal, $d_p$ is indeed a metric and so $L^p$ is a metric space.
The $L^p$ spaces are especially nice because they are not merely metric spaces, but also enjoy some other nice properties.

The $L^p$ spaces are complete: if $(f_n)$ is a Cauchy sequence of functions in $L^p$, then $(f_n)$ converges to a limit $f \in L^p$.
The $L^p$ spaces are normed vector spaces: you can add and subtract elements (functions) and multiply them by scalars, and there is a norm ("size") $\|f\|_p$ associated with each element. In fact, any normed vector space is a metric space if we define the distance between two elements $a$ and $b$ in terms of the norm: $d(a,b) = \|a-b\|$
The special case of $L^2$ is essentially an infinite-dimensional analogue of euclidean distance: $\left(\int |f(x) - g(x)|^2 dx\right)^{1/2}$ is the continuous equivalent of the euclidean distance $\left(\sum_{n=1}^{N} |x_n - y_n|^2\right)^{1/2}$.
There is also an inner product on $L^2$, defined by $\langle f,g\rangle = \int f(x) g(x) dx$ (assuming real-valued functions), which is analogous to the dot product $x \cdot y = \sum_{n=1}^{N}x_n y_n$. We can use this to extend the notion of orthogonality to functions: $f,g \in L^2$ are said to be orthogonal if $\langle f,g\rangle = 0$. The important Cauchy-Schwarz inequality holds in $L^2$, namely $|\langle f,g\rangle| \leq \|f\|\|g\|$. We can even define the angle between two functions analogously with the dot product: namely, the value of $\theta$ satisfying $\langle f,g \rangle = \|f\|_2 \|g\|_2 \cos(\theta)$.
Comment: Another note to solidify the fact that this is not a subset of $\Bbb R^n:$ for any $p$, the $L^p$ space over an interval does not satisfy the Heine-Borel theorem.  That is, there exist closed and bounded sets that are not compact.  In particular, the unit ball around $0$ is not compact.  For characterizations of compact sets in $L^p$ spaces, we need results like the [Arzela-Ascoli theorem](http://en.wikipedia.org/wiki/Arzel%C3%A0%E2%80%93Ascoli_theorem) (which applies for $p = \infty$).
Comment: Note: The special properties of $L^2$. as Bungo illustrates here, turn it into what is known as a Hilbert space, generalizations of Euclidean space.
Answer:
Why is it important to study the general properties of metric spaces?

What properties of metric spaces have you studied?  What have you gone on to do with them?
I agree that there is a tendency to introduce metric spaces at the beginning of an analysis course as a sort of "proper generality".  This naturally leads to the OP's question, because analysis is not the study of general metric spaces.  Rather, it really is the study of subspaces of $\mathbb{R}^n$ first and foremost, and then the study of certain spaces of real- and complex-valued functions on sets, which are often (though not always) endowed with a metric.  So if you haven't reached the point in analysis where you are studying spaces of functions, then in my opinion you are essentially correct in your point of view: you haven't needed to think about general metric spaces yet.
One more comment: the picture you produced is indeed one of the most common pictures one should have in mind when dealing with abstract metric spaces.  There is no doubt that the idea of a metric space comes first and foremost from Euclidean spaces, and our geometric intuition for these spaces is so strong that we should use it as much as possible when working in a metric space.  Intuition is a powerful and tricky thing: we don't need to be working in the setting in which our intuition was developed in order for it to be useful (or even indispensable).  I worried about this too as a young student: my instructors would talk about curves over an arbitrary field, or sometimes explicitly over a finite field, and they would still draw them as curves in the plane. But a curve over a finite field is a finite set of points [or, if you want to be more scheme-theoretically sophisticated than I was then, a countably infinite set of points: no help!].  It took me a while to realize that it was "okay" to use these pictures even when they clearly didn't literally apply, and in fact that it was very clever to do so.
On the other hand, the intuition gained in one setting is not always helpful in a genuinely different setting: that is more or less the definition of "genuinely different".  So one wants to supplement that intuition with some understanding of the differences.  One crisp way to phrase your question is:

What are some properties of any subset of Euclidean n-space that are not shared by a general metric space?

Here are three important ones:
1) They have at most continuum cardinality.
2) They are separable: equivalently (for metric spaces), they have a countable basis.
3) Bounded subsets are totally bounded.
In each case this holds because the property is possessed by Euclidean n-space itself and is hereditary: i.e., passes from a metric space to all of its subspaces.
Note that in any metric space, total boundedness implies separability implies at most continuum cardinality.  So in my opinion "bounded but not totally bounded" is a good answer to your question: in my experience this is precisely a property of a metric space that is hard to understand at first because it is possessed by subspaces of Euclidean space.  The property of total boundedness is often not made explicit in analysis courses, but it's certainly lurking under the surface.  Total boundedness is critically used in the standard "Lion-Hunting" proof of the Heine-Borel Theorem given in Rudin's Principles.  In fact, that argument is clearly some kind of family relative of the "abstract" theorem that a metric space is compact iff it is complete and totally bounded.  More plainly, whenever you have a metric space which is bounded not totally bounded, by taking its completion you get a metric space which is complete [hence "absolutely closed"] and bounded but not compact.  Most of the examples given in the other answers admit subspaces of this form.
Another important example is the Hilbert cube $\prod_{n=1}^{\infty} [0,1/n]$.  This metric space is compact, hence totally bounded.  It cannot be embedded in finite-dimensional Euclidean space for reasons of topological dimension theory [if there is some quick, elementary argument, I'd like to see it].  Every separable metric space can be topologically embedded in the Hilbert cube.
Most of the examples discussed above really live in the "uniform category", i.e., we could replace
isometric embeddings with uniformly continuous maps and have the same result.  Truly metric obstacles are quite different in nature.  Ivo Terek's answer is the optimal example of this: it is (the smallest) finite metric space which cannot be embedded in Euclidean space.  Being finite, any injection into $\mathbb{R}^n$ is uniformly continuous, so this is really about isometries rather than uniform maps.  By the way, spaces in analysis are usually only studied up to uniform equivalence (at the most, up to Lipschitz equivalence).  The study of isometries is called geometry.
Comment: Nice answer! ${}$
Answer: The discrete metric is not stupid at all, I do not know why you would say that.
(I am not kidding, I bet in the future you will appreciate it more and more :)
Take $\{0,1\}$ with, well, not much choice, the discrete metric, $d(0,1)=1$.
Now take $\{0,1\}^\omega$ with the product topology. One nice metric for it is $d(\langle x_0,x_1,..\rangle,\langle y_0,y_1,..\rangle)=2^{-k}$ where $k=\min\{m:x_m\not=y_m\}$. (True in this definition I do not really use the discrete metric, I do not need any metric on $\{0,1\}$, but we are talking after all about the countable power of the discrete topological space $\{0,1\}$, and it is most natural to think of $\{0,1\}$ as having the discrete metric.)
Of course $\{0,1\}^\omega$ is homeomorphic to the Cantor set, but nevertheless the above metric (different from the one inherited from the real line) is interesting, since it is non-Archimedean: Given any two open balls, they either do not intersect, or one is contained in the other.

(The above example is closely related to the Baire space as used in descriptive set-theory: A metric defined in a similar way as above, but on $\Bbb N^\omega$. See also this related answer.)
Comment: @SamuelHandwich Cantor sets are quite important. They are of course very nice counterexamples to some of our intuitive reasoning, but they also give us the notion of singular functions, which gets naturally extended into the notion of singular measures. This gets you the Lebesgue decomposition theorem. The first real application of singular functions I can think of is in defining continuous time stochastic processes which have reflecting boundaries. These are very physically motivated; for example, the problem of heat diffusion in an insulated body corresponds to this situation.
Comment: I just say discrete metric is stupid because it is the easy example when you are wrong, but mostly it says nothing. It is like the trivial group, if you say all groups have non-trivial normal subgroup, the trivial group tells you no, but if you ask for a group with no non-trivial normal subgroups, the trivial group has one, but it is the stupid example. Maybe I am just not appreciate until I am old enough in analysis.
Comment: Anyway, I do like this non-Archimedean, even though it is pretty pathologic. Does it come up in another place sometimes?
Comment: @Samuel: The class of all discrete metric spaces is much more interesting than the trivial group! A discrete metric space is exactly as interesting as its underlying set, and arbitrary sets are very interesting.  There are also many topological constructions that take discrete spaces as input and yield highly nondiscrete spaces as output.  For instance the Stone-Cech compactification of (even) a countably infinite discrete space is a highly interesting mathematical object.
Comment: To add to this old thread, and to address the questions raised by @SamuelHandwich, the Cantor set is so far from pathological that is appears naturally in several branches of mathematics, albeit with different metrics. Number theory: For a prime $p$, the ring of integers $\mathbb Z_p$ in the field of $p$-adic numbers $\mathbb Q_p$ (described in my answer to this question),  is a Cantor set. Geometric group theory: The space of ends of the free group $F_n$, aka the Gromov boundary of $F_n$, is a Cantor set. Dynamical Systems: The recurrent set of the Smale horseshoe is a Cantor Set.
Answer: An example is the Schwartz class $S(\mathbb{R^n}) = \{f(x): \mathbb{R}^n \to \mathbb{C} : f(x) \in C^{\infty}(\mathbb{R}^n)$ and $\operatorname{sup}_{x \in \mathbb{R^n}}|x^{\alpha}\partial^{\beta}f(x)|< \infty$ for all multi-indices $\alpha, \beta$}
with the metric $$d\left( f,g \right) =\sum _{\alpha, \beta }{\frac{1}{{2}^{|\alpha|+|\beta|}}}\frac{{\left\|f-g \right\|}_{\alpha,\beta }}{ 1+{ \left\| f-g \right\|  }_{ \alpha,\beta } }$$
where $||f||_{\alpha, \beta} = \operatorname{sup}_{x \in \mathbb{R^n}}|x^{\alpha}\partial^{\beta}f(x)|$
The Schwartz space itself is nice because it provides a convenient space in which we can do Fourier analysis - as all functions and their derivatives of all orders decrease rapidly, we don't have to worry about convergence of the integral in the definition of the Fourier transform and can define the FT for all derivatives as well.  The Fourier transform defines an automorphism of the Schwartz class.
Furthermore, $S(\mathbb{R^n})$ is complete with respect to this metric and is dense in $L^p(\mathbb{R^n})$ for $p \geq 1$ (see Bungo's answer for more on those spaces).   The latter is because the space $C_c^{\infty}(\mathbb{R^n})$, the space of smooth, compactly supported functions, is dense in $S(\mathbb{R^n})$ itself.
Note that the fact that $L^2$ is a Hilbert space allows us to do Fourier analysis on $L^2(\mathbb{R^n})$ itself.
Answer: Here is an example that comes from number theory rather than from analysis.
Euler believed that if you fix a prime number $p$ then infinite series of the form
$$a_0 + a_1 p + a_2 p^2 + a_3 p^3 + \cdots
$$
make some kind of mathematical sense, where the coefficients are chosen in $\{0,1,…,p-1\}$. More generally one might wonder how to make sense of a similar series starting not just at $0$ but at any integer,
$$a_k p^k + a_{k+1} p^{k+1} + \cdots
$$
In modern number theory a series as above is called a "$p$-adic number".
The field of $p$-adic numbers is constructed formally from the rational numbers $\mathbb{Q}$ by using metric completion, quite like the way in which $\mathbb{R}$ is constructed from $\mathbb{Q}$ using metric completion, but the metric is very different.
Formally, one defines a metric on the rational numbers $\mathbb{Q}$ by the formula
$$d_p\biggl(\frac{a}{b},\frac{c}{d}\biggr) = p^{-i}
$$
where the exponent $i$ is defined by the equation
$$\frac{a}{b} - \frac{c}{d} = p^i \frac{e}{f}
$$
and the integers $e,f$ have no factors of $p$. This metric $d_p$ on $\mathbb{Q}$ is incomplete. The space of $p$-adic numbers, denoted $\mathbb{Q}_p$, is defined to be the metric completion of $\mathbb{Q}$ with respect to the metric $d_p$.
One way to sum this all up is to notice that starting from the series above, the sequence of partial sums
$$S_m = a_0 + a_1 p + a_2 p^2 + \cdots + a_m p^m
$$
is a Cauchy sequence with respect to the $p$-adic metric $d_p$, and so the infinite series does indeed exist as an element of $\mathbb{Q}_p$.
Answer: As Bungo said in the comments, you can also consider the $\ell^p(\mathbb{N})$ spaces.
For $1 \leq p < \infty$ they're the sets of summable sequences to the p-th power:$$\ell^p = \bigg\{x \colon \sum_{n = 1}^{\infty} |x_n|^p < \infty\bigg\}$$
With the norm $$\|x\|_p = \bigg(\sum_{n = 1}^{\infty} |x_n|^p\bigg)^{1/p} $$
And for $p = \infty$
$$\ell^{\infty} = \bigg\{x \colon \sup_{n \in \mathbb{N}} |x_n| < \infty\bigg\}$$
That is, the sequences of all bounded functions, with the norm $\|x\|_{\infty} = \sup_{n \in \mathbb{N}} |x_n|$.
They have the same properties that Bungo listed, so I wont list them again. This is because an $\ell^p$ space is an ${L}^p$ space wich is integrating the functions that take natural numbers under what is called a counting measure, this will be a bit more clear when you take a course that teaches Lebesgue integration.
But you can also consider two metric spaces more related to $\ell^p$, $c$ and $c_0$, the first one, $c$, is the sets of all convergent sequences under the $\|\cdot \|_\infty$ norm, and $c_0$ is the set of all convergent sequences to $0$ under the same norm.
You can also order these spaces in the following form
$$\ell^1 \subseteq \ell^2 \subseteq \dots \subseteq c_0 \subseteq c \subseteq \ell^{\infty}.$$
For more on $\ell^p$ spaces and metric spaces I could refer you to:

Real analysis. Carothers (a third of this book is dedicated to metric spaces), followed by
A short course on Banach space theory

or indepently

Infinite Dimensional Analysis a Hitchiker's guide.

Another metric space (used in Information Theory) you can consider is, taking finite tuples or sequences of zeros and ones with the same lenght $n$, and defining over them what is called a Hamming distance:
$$d(x,y)  = \sum_{\substack{x_i\neq y_i\\  i =1}}^n  1 = \sum_{i = 1}^n |x_i - y_i|$$
Here the right hand is the $\ell^1$ distance, but the middle one would still make sense if you consider for example instead of zeros and ones, vectors of natural numbers.
A graphic example, taken from, Red shows the distance from $011$ to $100$, $d(011,100) = 3$, and blue from $111$ to $010$, $d(111,010) = 2$.
Answer: The Hilbert space $(z_1,z_2,z_3,\ldots)$ where each $z\in\mathbb C$ and $\sum_{n=1}^\infty |z_n|^2<\infty$ certainly comes up.  It is isomorphic to the space of functions $f:[0,1]\to\mathbb C$ with the metric $d(f,g)=\int_0^1 |f(x)-g(x)|^2\,dx<\infty$.
Another example is spaces with the uniform metric $d(f,g)=\sup \{ |f(x)-g(x)|: x\in\text{some domain} \}$.
Smooth manifolds can have metrics.  And then one speaks of things like curvature.  On one very well known manifold one can find three points $a,b,c$ that are a degenerate triangle (i.e. equality holds in the triangle inequality) and a fourth point whose distance from each of the three is $1$.
Comment: What is the well-known manifold?  I think its triangle is the same one as Ivo Terek example.
Comment: I had in mind the sphere: suppose $a,b,c$ are on the equator and $d$ is the north pole. ${}\qquad{}$
Answer: Consider the space of all continuous functions on $[0,1]$ with the sup norm, or the integral norm.
Answer:
For this question: In general, what are the useful, non-obvious metric spaces that a student should keep in his mind when learning analysis?

What about distance on $\mathcal{M}(X)$ the set of all Borel probability measures on $X$? Wasserstein distance for example. Let $(X,d)$ a metric space and define
$$
d_W,_p(\mu,\nu)=\bigr(\inf_{m\in \prod(\mu,\nu)}\int_{X\times X}d(x,y)^pd_m(x,y)\bigl)^{1/p}
$$
where $\prod(\mu,\nu)$ is the set of all couplings of $\mu$ and $\nu$.
Another one is Lévy–Prokhorov metric.
Answer: The truth of the matter is is that if you only consider pairs of points within a metric space and only do reasoning with pairs of points at a time, then the pictures you draw in $\mathbb{R}^2$ still carry over very well to arbitrary metric spaces. However, if you start asking about properties that concern the entire metric space or subsets of the metric space, you need to be careful.
There is one phrase from a professor that really helped me detach metric spaces from Euclidean space:

Metric spaces do not necessarily represent spatial relationships. They measure distance.

The point to his quote, that I inferred, is that distance between two objects can be construed in many different senses other than just spatial. As just a few examples, you can measure distances by how long it would take you to get somewhere, how difficult it is to accomplish a task, how grand of a miracle would need to occur to attach two events, how much of a technological leap would be necessary to get somewhere.
Don't get hung up on distances as representing spatial relationships, and you'll be well on your way.
In my experience, there are five properties of $\mathbb{R}^n$ (off the top of my head) that could potentially foul up your reasoning because they don't hold for arbitrary metric spaces.

$\mathbb{R}^n$ is second-countable.
The closure of $\{y\in\mathbb{R}^n: d(x_0,y)<r\}$ coincides with the set $\{y\in\mathbb{R}^n: d(x_0,y)\leq r\}$.
The set $\{y\in\mathbb{R}^n: d(x_0,y)\leq r\}$ is compact.
If you have a sequence $\{B_n\}$ of closed balls such that $B_{n+1}\subseteq B_n$. Then the intersection $\bigcap B_n$ is non-empty; i.e. $\mathbb{R}^n$ is spherically complete.
$\mathbb{R}^n$ does not have "local groups" or "sets of points which are equally easy to get to from another fixed point". By this I mean that if you have two distinct points $x$ and $y$ from $\mathbb{R}^n$ and you have another point $y_2$ which is "close to $y$ in comparison to $x$" then it still might be possible that it is strictly easier to get to $y_2$ from $x$ than it is get to $y$ from $x$.

The first property sort of says that $\mathbb{R}^n$ isn't very "wide". The second property says that points which are $r$ units away from some fixed point are still close to points which are less than $r$ units away from that same fixed point. The third property sort of intimates that $\mathbb{R}^n$ doesn't have "very many dimensions". The fourth property says that if you give somebody a countable set of narrower and narrower commands (but not necessarily a set of commands that uniquely identify one course of action), they'll be able to satisfy the entire set of your commands. I'll expand on the fifth property with ultrametric spaces.
There are several examples of metric spaces that undermine each of these properties. Function spaces, such as $\ell^2$ and the set of bounded functions on $[0,1]$ with the sup norm, are usually the best places to find counterexamples to these criteria.
However, my favorite example of a metric space which does not behave like Euclidean space at all (and still are extremely relevant to several different areas of study) has to be ultrametric spaces, which typify the fifth property that I bulleted. Here are a couple of systems that exemplify ultrametric spaces:

The universe. Where distance is measured by the technological sophistication needed in order to get to different places in the universe. It's far easier to travel within our solar system than it is to travel to the next closest solar system. So much so that all the points in our system might as well be the same distance from earth in comparison to points in that solar system. Likewise it is far easier to travel within our galaxy than it is to travel to the next closest galaxy (at least until Andromeda hits us). And then it's far easier to travel to the next galaxy in our local cluster than to leave our cluster (which we probably won't ever do).
The Earth. Where distance is measured by the type of transportation and the type of roadways you would need to use to arrive at a destination in a timely manner.
Complex biological organisms. Where distance is measured by the number of organ systems that need to handle a molecule to get it to a location where it can be used.
Algorithms with parallel subprocedures and parallel sub-subprocedures and etc... which accepts and spits out the same type of data structure. Where distance is measured by the hierarchical path that an input has to take in order to be transformed into another input.

More concrete, and more rigorous, examples of ultrametric spaces are given in the other answers. The $p$-adic rationals $\mathbb{Q}_p$, for a fixed prime $p$, are perhaps the most relevant example you need to know to continue to study analysis or to enter analytic number theory.
Comment: would you consider discipline of analysis to be about spatial relationships? about distance (like metric space)? or, about relating distance to spatial relationship?
Comment: @SamuelHandwich analysis is about inequalities. Implicit (through the use of sequences or limits) or explicit. Metric spaces provide the abstract setting in which to study the triangle inequality in its greatest generality. Despite its modest formulation, the triangle inequality (and its various instances) is the most used inequality in analysis.
Answer: I am surprised nobody mentioned the Levenshtein distance which is a metric between strings - yet strings are no vectors in $\mathbb R^n$.


What's a dashed line between two classes in UML?

Question: The image bellow illustrates a data model of multiple if we could say java classes. I am familliar with all the other type of arrows except the dashed line marked with red pencil in the image.
Comment: I think it is supposed to represent the relation between baseStore and cmsSite. A store can be associated with multiple sites and a site can be associated with multiple stores.
Comment: yes it is right. the issue it that why dashed line instead of a simple line. is the illustration wants to points to sth else.
Answer: Simply: nonsense. At least no valid UML. It might be a dependency but then it misses the arrow to show which depends on what.
Further

the * name label is  meaningless.
The filled arrows are wrong since they are reserved for the extendsrelation used to define stereotypes.
That dashed line bottom right is invalid as well.

My advice: throw that book where you got that from as far as possible.
Answer: In UML that dashed line is an anchor, it has no special/strong meaning
A typical/standard use of an anchor is between an element and a note, helping to say the note concerns that element and not an other close to it
In your case its use is obscur, and it is more with the label * as already said
Comment: I know that plain dashes lines are also used to link notes. But I never heard of the term anchor. The specs don't use that  term too. Where is that from? Interestingly I could not find the definition of a note in UML 2.5. Might be the needle in a haystack?
Comment: @qwerty_so I use "anchor" to name the corresponding button in BoUML since the very first version, I did not created that naming so it comes from somewhere. For "note" see _§7.2.4 Notation_ saying _A Comment is shown as a rectangle with the upper right corner bent (this is also known as a "**note** symbol")_. As you know a note can also show a _constraint_
Comment: I see and yes, I know :-) Thanks for the pointer. I remember the drawing but sometimes it's really that needle in a haystack.
Answer: qwerty_so gave you an answer related to UML.
In case you are wondering about the technical details of the relationship between BaseStore and CMSSite in Hybris, it's many-to-many.


Proving that $\sum_{n=1}^{\infty} f(a{_{n}})$ converges absolutely

Question: Let $(a_{n})_{n}$ be a sequence of non zero real numbers such that the series $$\sum_{n=1}^{\infty} a{_{n}}$$ converges absolutely. Let $f:\mathbf{R}\rightarrow\mathbf{R}$ be a function with the property that $$\lim_{x\to 0} f(x)/x$$ exists and is finite. Show that $$\sum_{n=1}^{\infty} f(a{_{n}})$$ converges absolutely.
Comment: Please give more [context](http://meta.math.stackexchange.com/a/9960). Providing context not only assures that this is not simply copied from a homework assignment, but also allows answers to be better directed at where the problem lies and to be within the proper scope.
Answer: Note that the convergence of $\sum_{n=1}^{\infty} a{_{n}}$  implies
$$\lim_{n\to\infty}a_n= 0$$
Hence $$\lim_{x\to 0} f(x)/x= \lim_{n\to \infty} f(a_n)/a_n= l$$
for $\varepsilon= |l|+1>0$ there exists N such that for $n>N$ we have
$$||f(a_n)/a_n|-|l||\le|f(a_n)/a_n-l|<|l|+1\implies |f(a_n)|\le (2|l|+1)|a_n|$$
that is $$\sum_{n=N}^{\infty}|f(a_n)|\le(2|l|+1) \sum_{n=N}^{\infty}|a_n|<\infty\ $$
Comment: down voter explain it may help to understand what is wrong
Comment: Guy. Nice answer.+1
Comment: @PeterSzilas   unfortunately there is a down here
Comment: Guy. Not worth worrying.A nice solution!Let's look forward.
Answer: Hint: Denote the limit of $f(x)/x$ as $L$ whenever $x\rightarrow 0$. Try to argue that $\left|f(a_{n})\right|<(|L|+1)|a_{n}|$ for large $n$.


Circuit tester trips new GFCI

Question: I replaced a non-protected receptacle with a GFCI type and now my circuit tester trips the GFCI as soon as it is plugged in.  The receptacle tested fine before replacement, ground, neutral, hot, etc.  I've double checked the hot/neutral/ground connections.  I've also tried it with the downstream load disconnected.
The GFCI trips the moment I plug in my circuit tester (before pushing the test button).  Otherwise things check out OK.  I can plug in a power tool without it tripping.  Also, the integrated test/reset button work correctly.
I've read that the integrated test button is the only one that truly matters. Is this correct or should I be concerned? I'm sure a home inspector will red flag this if their tester has the same result.
Update
My tester is by "Commercial Electric".  The tester is one of the palm sized three prong type with three leds to indicate the condition of the circuit and a button on top to test GFCI. It's new from the local box store.
Comment: I would check your tester on another GFCI outlet. It is possible the trip function of the tester is stuck. If your outlet runs any tools or devices I believe the tester is bad. If the Test & reset buttons on the outlet work I would bet the tester is bad.
Comment: It depends on how your particular tester is built. If it tests against the ground pin, then it creates the exact live-to-ground current that's supposed to trip GFCI. Powertool is not a good test device, as they're usually designed as insulated - they don't have a ground pin in their plugs. Try something with grounded plug, a desktop computer or 3-pin laptop charger.
Comment: What's the make and model of the tester?  Is the tester new, old, in good condition, etc.?
Answer: As well it should.
Normally, loads are connected between hot and neutral.  Appliances are not supposed to connect hot or neutral to ground; ground is only a shield.
The GFCI compares current on the hot and neutral wires.  They should be the same.  If they are not, current has found another route, possibly through the grounding system (which isn't supposed to happen) and potentially through some poor human.
Circuit testers are trying to test whether ground is connected... cheaply.  They mis-use "hot" as a power source, by connecting a light bulb between hot and ground.  If ground is connected correctly, this will light.
In other words, it intentionally creates a hot-ground fault (by sticking a light bulb there).  This is exactly the condition GFCIs are designed to detect.
I'm not talking about any ground-fault-test the tester may also have.
So why do testers often work?  With a perfect GFCI, they wouldn't work.   I suspect it is because GFCI's have detection thresholds above zero, and that is often enough for these testers to "get away with it".  I even think there may be a tacit agreement among manufacturers for this, but obviously, lower sensitivity impinges safety.  Remember a shock which only stuns you can kill you with secondary effects like falling or drowning.
So either your GFCI is pretty good, or your tester is pretty bad.
Comment: I'm speaking of its regular function, **not any GFCI test** it may also have.  Admittedly I don't know which circuit tester he's talking about.  But unless the detector strings a long cable back to a reference ground, it can only test ground by testing its relationship with one of the other two pins (hot or neutral).  Any such test must, inherently, be a ground fault. A theoretically perfect GFCI would always detect this; you may have gotten away with it due to detection thresholds.  I am saying, *don't bet on that*.
Comment: Note that the GFCI trips before I push the test button on the tester, but operates normally with the test button on the plug.
Comment: I've never taken one of these apart, but I'm not sure that's how they work.  When plugged in, the unit should light up properly (assuming the wiring is proper). When the test button on the unit is pressed, it simulates a ground-fault to trip the GFCI. In normal use, the GFCI should only trip when the test button on the tester is pressed.
Comment: @Harper, In the back of my mind that's kinda what I wondered.  Could my new GFCI receptacle be sensitive enough to detect the circuit tester and trigger a fault.  It seemed unlikely that the manufacturer of the tester would not have caught that, but what do I know?
Comment: Reducing the trip threshold below a certain point will increase the frequency of false-trip events caused by things like capacitive coupling; false trips don't increase safety.
Comment: Yes, anonymous, if you connect a light bulb between hot and ground, it should trip the GFCI.  You have placed the bulb in the same position a human would be if he was being electrocuted. Understand in mains power wiring, neutral is the normal current return, not ground.  This differs from low voltage electronics where GND is indeed the current return.  Here, ground is none but a safety shield.
Answer: The short answer is yes, some testers can give inconclusive results. The GFCI receptacle is able to detect the GFCI and an incorrectly wired load can trip the receptacle breaker.
I puchased a new GFCI/circuit tester and it properly identified a 'down stream' load with the hot and neutral reversed. I swapped the hot and neutral on the second outlet and all was good.

Circuit tester trips new GFCI


Count number of sentences using REGEX and ignoring acronyms

Question: I try to count the number of sentences in a text using a regex. I came up with a regex1 finding all points:
([^.!?\s][^.!?]*)

After that I tried to find most of the acronyms by the following regex2:
([A-Z]+[a-z]{0,3}\.).

However I have a few problems:

If the acronym is at the end of a sentence, it is found (e.g. Since 20,000 BC.) by the regex2 formula. This is not intended, I only want to find acronyms in a sentence.
If we assume, that problem1 is solved, I want to merge both regex formulas together so that the final formula only outputs the real number of sentences. As for example we can consider the following text from Wikipedia:

The National Aeronautics and Space Administration (NASA) is the United
  States government agency responsible for the civilian space program as
  well as aeronautics and aerospace research.
President Dwight D. Eisenhower established the National Aeronautics
  and Space Administration (NASA) in 1958[5] with a distinctly civilian
  (rather than military) orientation encouraging peaceful applications
  in space science. The National Aeronautics and Space Act was passed on
  July 29, 1958, disestablishing NASA's predecessor, the National
  Advisory Committee for Aeronautics (NACA). The new agency became
  operational on October 1, 1958.[6][7]
Since that time, most U.S. space exploration efforts have been led by
  NASA, including the Apollo moon-landing missions, the Skylab space
  station, and later the Space Shuttle. Currently, NASA is supporting
  the International Space Station and is overseeing the development of
  the Orion Multi-Purpose Crew Vehicle, the Space Launch System and
  Commercial Crew vehicles. The agency is also responsible for the
  Launch Services Program (LSP) which provides oversight of launch
  operations and countdown management for unmanned NASA launches.
NASA science is focused on better understanding Earth through the
  Earth Observing System,[8] advancing heliophysics through the efforts
  of the Science Mission Directorate's Heliophysics Research Program,[9]
  exploring bodies throughout the Solar System with advanced robotic
  spacecraft missions such as New Horizons,[10] and researching
  astrophysics topics, such as the Big Bang, through the Great
  Observatories and associated programs.[11] NASA shares data with
  various national and international organizations such as from the
  Greenhouse Gases Observing Satellite.

The above text has 9 sentences.
Regex1: 12 matches (D., U., and S. are considered as "full stops")
Regex2: 3 matches (D., U., and S.)
What I need now is a better regex1 formula to only find acronyms in a sentence and then "merge" both regex formulas to receive all sentences.
If merging both formulas is not possible (for any plausible reason), then only consider problem 1 because at the moment my JAVA program use both formulas seperated:
public void breakIntoSentences()
{
    //Find all points
    Pattern p = Pattern.compile("([^.!?\\s][^.!?]*)");
    Matcher m = p.matcher(content);

    int allPoints = 0;
    while(m.find())
        allPoints++;

    //Find all acronyms with length 0-4
    p = Pattern.compile("([A-Z]+[a-z]{0,3}\\.)");
    m = p.matcher(content);

    int allAcronyms = 0;
    while(m.find())
        allAcronyms++;

    numberOfSentences = allPoints - allAcronyms;
}

Thank you in advance for the help
Comment: You want only words, right? How about `\w+([^\W\d])` ? http://regexr.com/3ar0d Using PatternMatcher you can count how much you have them.
Comment: No, the goal is to extract sentences from what I read. To count sentences he wants to extract them into groups and then count them.
Answer: Here's a pattern:
.+?(?:(?<![\s.]\p{Lu})[.!?]|$)

Demo

.+? is here just to match a full sentence. If you simply want a count, you can replace it with .
(?<![\s.]\p{Lu}) means not preceded by an uppercase letter itself preceded with a space or period. This is used just before [.!?] which checks for an end of sentence. This seems to handle the acronyms right.
$ is there just to force the non-greedy .+? at the start to match until the end of the text just in case the text doesn't end with a period.

This regex handles [6][7] as part of the next sentence. If that's not acceptable, you could tweak the pattern a bit by adding [\d\[\]]* just after [.!?].
Comment: Thank you very much! This really counts the number of sentences correctly in both examples :) However if 2 acronyms are one after each other (e.g. Dr. Prof. Someone has encountered a problem.) the formula counts incorectly (here 3)
Comment: That's absolutely true Lucas! I don't expect to get a perfect one but if it is possible to exclude all acronyms (your previous formula) and all double acronyms you could be correct in more than 90% of all cases. Because your last solution works well with "Dr. Prof." but if you switch them "Prof. Dr." it fails logically. Hence, if it is possible and if you could provide my a formula ignoring all double acronyms, I would be satisfied :)
Answer: It looks like all you want is something that checks that there was no capital before the period. This is pretty easy to do:
((?:[A-Z]\.|[^\.!?])+)[\.!?]

This uses an option of any non-sentence ending symbol or a capital followed by a period.
The more than one character also allows you to avoid recording three sentences for:

Something like this...
Comment: Your example has the same number of matches than my regex formula (15). So the acronyms are not excluded as intended.
Comment: @Flu You can see it working here: https://regex101.com/r/tO5bC6/1 It's definitely skipping over acronyms. And I'm getting a 9 sentence count?
Comment: @Flu I just tested the regex with your code here: http://ideone.com/8SqA5k definitely gives my 9 *not* 15.
Comment: You are write I tested with the wrong text... My mistake! It works but has the same problem than Luca's formula (https://regex101.com/r/tO5bC6/1).
Comment: @Flu Of course these do, they are both ignoring periods following a capital letter. You can add other things to ignore but you'll have to do that by hand, cause without it being a capital there's no way for a regex to tell the difference between "Jon." and "Mr." To add "Dr." and "Prof." to my regex you could just do: `((?:[A-Z]\.|Dr\.|Prof\.|[^\.!?])+)[\.!?]` But as you can see you'd have to start adding a lot of exceptions to find every acronym.


How to pass EditText to another activity?

Question: Intent intent = new Intent(this,Name.class);
intent.putExtra("key", et.getText().toString());
startActivity(intent);

Intent intent = getIntent();
String str = intent.getStringExtra("key");
tv.setText(str);

From using above code I can get a string value at other activity, but I need editText object at another activity.
can anyone give Idea ?
Thanks
Comment: Can't come to understand why people wants EditText object instead of its value?
Comment: And why do you need to pass the `EditText` object to another `Activity`?
Comment: why you want to pass the editText to another activity ? can give proper reason.
Comment: did you want to update/modify the edittext object from other activity...
Answer: Why not send the ID and then use findViewByid() on the receiver Activity?  Hope this helps:
Intent intent = new Intent();
String name="textView";
int value=EditText.getID();
intent.putExtra(name, value);
setResult(RESULT_OK, intent);

On receiver Activity:
private static final int REQUEST_CODE=1;
private int id;
private EditText et;
private Intent i;

i = new Intent(this,Name.class);
startActivityForResult(intent, REQUEST_CODE);
et = (EditText)findViewById(id);

protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    if (resultCode == RESULT_OK && requestCode == REQUEST_CODE)
    {
        if (data.hasExtra("textView"))
        {
            //Get the selected file.
            id = data.getExtras().getInt("textView");
        }
    }
}

Answer: Hmm .. using a Singleton static class you can achieve the same. Store the reference to your edittext in the SingleTon class in one activity and the retrieve it back in another activity and achieve what you want to do. Thats' one of the possible work around in Java for your problem.
As far as android SDK is concerned you can't pass a view obj reference in Intent to another activity.
Answer: Well, in spite of all yells about uselessness of sending EditText to Activity I would say it can be done. For instance declare your own class which extends EditText and also implement Parcelable interface
public class MyEditText extends EditText implements Parcelable
{
       //a lot of things to be done...
}

In this case you will be able easily send MyEditText as Parcelable to another Activity
Intent intent = new Intent(this,Name.class);
MyEditText et=new MyEditText(this);
intent.putExtra("key", et);
startActivity(intent);

For sure utility of this approach is still disputable.


Orthonormality of Hermite function

Question: I was wondering if someone could tell me when the following relation holds?
where $H_{n}(x)$ are Hermite polynomials and $\delta(x-x')$ is Dirac delta function:
$$
\sum_{n=0}^\infty
\frac{1}{\sqrt{\pi}2^{n}n!}
e^{-\frac{1}{2}x^{2}-\frac{1}{2}x'^{2}}
H_{n}(x)H_{n}(x')
=
\delta(x-x')
.
$$
I asked this because I am trying to solve this:
https://physics.stackexchange.com/questions/455890/photon-number-representation-of-a-position-eigenstate
Comment: See https://en.wikipedia.org/wiki/Hermite_polynomials#Completeness_relation
Comment: For all real $x$ and $x'$, I would assume.
Comment: how may i proceed to prove it? @G.Smith
Comment: I have a related question, ado the same completeness relations exist for any orthonomal basis dense in L^2? Thank you in advance!
Answer: Denote the left hand side of your identity by $K(x,x')$. The identity $K(x,x')=\delta(x-x')$ is an identity between generalized functions. What it's really saying is that
$$
\int_{-\infty}^{\infty} K(x,x')f(x')dx' = f(x)
$$
for any $x$ and any reasonably nice function $f$. In fact it's enough to prove this for $f(x)=e^{-x^2/2} H_m(x)$ a Hermite function, since the Hermite functions are s complete orthogonal system in $L_2(\mathbb{R})$. For this $f$ the claim follows immediately from the orthogonality relation for the Hermite polynomials, since when we perform the integration for the $n$th term in the sum, we get 0 if $n \neq m$ and the correct thing for $n=m$.

Orthonormality of Hermite function


Finding the maxima of $f(z)=\frac{1}{z^3+z^2+z+1}$ and the integral $\int_Cf(z)\mathrm dz$

Question: Could you please explain to me how to find the maxima of $f(z)=\frac{1}{z^3+z^2+z+1}$ and the integral $\int_Cf(z)\mathrm dz$, where $C$ is an anticlockwise circle of radius $2$ centred around $(0,0)$?
For the maxima, I made the assumption they would be at the same points as for $z^3+z^2+z+1$ so I calculated $3z^2+2z+1=0$ giving $z=\frac{-2\pm\sqrt8}{6}$ and substituted both z into the original $f(z)$, is this correct, and is there a simpler way?
For the integral, I calculated $z^3+z^2+z+1=(z+1)(z+i)(z-i)$ but am not sure how to proceed from here.
Comment: What exactly do you mean by maxima, maxima of $|f|$? You can't achieve it since $f$ has poles. And if you calculate maxima of $|z^3+z^2+z+1|$ you most definitely won't get maxima of $|f|$ since $x\mapsto 1/x$ is decreasing on $(0,+\infty)$. Or you want to know _local_ extrema?
Comment: $f(z)=o\left(\frac{1}{|z|}\right)$ as $|z|\to +\infty$, hence if $C$ is a contour enclosing $-1,\pm i$ we have that $\oint_{C} f(z)\,dz = 0$ by the residue theorem.
Comment: You must give us $C$, because the integral depends on it.
Comment: Sorry, C is an anticlockwise circle of radius 2 centred around (0,0).
Comment: Use partial-fraction decomposition and cauchy's integral formula
Comment: Local maxima. So the points at which z stops going downwards and starts going upwards, or vice versa. This should be when $\frac{\partial f}{\partial z}=0$, right?
Answer: We have a partial-fraction decomposition
\begin{align}f(z)&=\frac{1}{2(z+1)}+\frac{1-z}{2(z^2+1)}\\
&=\frac{1}{2(z+1)}+\frac{i(1-z)}{4(z+i)}-\frac{i(1-z)}{4(z-i)}
\end{align}
We then obtain by cauchy's integral formula
\begin{align}
\oint_C f(z)dz=2\pi i\Big(\frac{1}{2}+\frac{i(1+i)}{4}-\frac{i(1-i)}{4}\Big)=0
\end{align}


Which one is better for drag sign

Question: I have checked some websites and found these two signs as drag symbol:

Which one is better?
Comment: You really should test this with your users to which they understand (or if they need something altogether different)
Answer: Before reading your question, I saw an image with a menu and a second image with two lines.
I think that not just the number of lines influences, but also the location.

But I still thinking the three lines looks like a hamburger menu.
The standard for dragging is the dotted line, and in this case the number of lines or direction is not relevant.
Answer: Hamburger, used for opening/closing a site's navigational structure springs to mind first. They are identical to your example, usually seen with three lines, but now, with minimalism as important as ever, they are often seen only on two lines like your second example. Honestly, I'd avoid anything that could be misinterpreted. In a way, the more obvious the better.

Which one is better for drag sign


Changing int to double changes my result to zero

Question: If I leave all variables  as int I get 32. The division is supposed to give me 32.5 so I thought that changing everything to double would do it, but it just gives me zero...
Here is the code (everything in int):
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average);

int main(int argc, char *argv[])
{
    int tableau[4] = {30, 50, 50};
    int *x = 0;
    int *average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);

    printf("The average is %d\n", average);

    return 0;
}

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average)
{
  int i = 0;

  for (i = 0 ; i < tailleTableau ; i++)
  {
  *x = *x + tableau[i];
  }
  *average = *x/tailleTableau;

}

So this works and gives me 32... Now if I change everything to double and %d to %f in the printf function, it gives me zero and I don't understand why...
Comment: No need to make anything but `average` a double, apart from casting either the dividend or the divisor.
Comment: you don't get any warnings from your compiler with this code?
Comment: No, I didnt get any warnings.. Should I?
Comment: @TimurRidjanovic please don't forget to accept the answer which helped you the most
Answer: There is lots of mistakes in your code. I corrected all of them
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, double *average);

int main(int argc, char *argv[])
{
    int tableau[4] = {30, 50, 50};
    int x = 0;
    double average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);

    printf("The average is %lf\n", average);

    return 0;
}

void sommeTableau(int tableau[], int tailleTableau, int *x, double *average)
{
  int i = 0;

  for (i = 0 ; i < tailleTableau ; i++)
  {
  *x = *x + tableau[i];
  }
  *average = (double)(*x)/(double)tailleTableau;

}

Comment: Learning is good!..note all the positions where I made changes in your code...also read answer posted by others..Good-Luck
Answer: One of your problems lies here:
int *x = 0;
int *average = 0;

sommeTableau(tableau, tailleTab, &x, &average);

Those first two lines should be:
int x = 0;
int average = 0;

This is evident from the warnings you should be getting, assuming you're using a decent compiler:
qq.c: In function 'main':
qq.c:13: warning: passing argument 3 of 'sommeTableau' from incompatible pointer type
qq.c:4: note: expected 'int *' but argument is of type 'int **'
qq.c:13: warning: passing argument 4 of 'sommeTableau' from incompatible pointer type
qq.c:4: note: expected 'int *' but argument is of type 'int **'

In addition, you don't need _everything to be a double, just the average, so you should only change the type of that variable and match that with the parameters passed to the function.
It will also be necessary to cast the total *x to a double before doing the division, so that it knows you don't mean integer division.
With those changes, the output changes from:
The average is 4.000000

(for me) to the correct:
The average is 32.500000

See the following program for more detail:
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, double *average) {
    int i;
    for (i = 0 ; i < tailleTableau ; i++)
        *x = *x + tableau[i];
    *average = ((double)(*x))/tailleTableau;
}

int main (void) {
    int tableau[4] = {30, 50, 50};
    int x = 0;
    double average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);
    printf("The average is %lf\n", average);

    return 0;
}

Answer: You are passing x and average as null pointer. Thats why your code is giving segmentation fault.
As per you describtion please check(http://codepad.org/z8fVUTe5).
#include <stdio.h>
#include <stdlib.h>

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average);

int main(int argc, char *argv[])
{
    int tableau[4] = {30, 50, 50};
    int x = 0;
    int average = 0;
    const int tailleTab = 4;

    sommeTableau(tableau, tailleTab, &x, &average);

    printf("The average is %d\n", average);

    return 0;
}

void sommeTableau(int tableau[], int tailleTableau, int *x, int *average)
{
  int i = 0;

  for (i = 0 ; i < tailleTableau ; i++)
  {
  *x = *x + tableau[i];
  }
  *average = *x/tailleTableau;

}

Output:-

The average is 32
Answer: Something is terribly wrong here -- you're defining x and average as pointer variables in main, which if you are lucky is the same size as an int, but may result in undefined behavior.
Remove the * from the local variable declarations of x and average in main and it may actually work.
Also, in sommeTableau, both operands of the division (*x and tailleTableau) are int, so integer division is performed and the remainder discarded prior to assignment to *average.
Comment: I just changed average to double and put %lf in the printf function, and it still gave me a zero.
Comment: @TimurRidjanovic Never mind, that isn't the problem, it's the declaration of `x` and `average`.
Comment: Ok, I did that and it gave me 32.0000 .How come I'm not getting 32.5?
Comment: If both operands of a division are integer, the division is performed in integer arithmetic and the remainder is discarded.  It doesn't matter that the result is being assigned to a floating-point variable.
Answer: int *x = 0;
int *average = 0;

This is defining two pointers and setting the pointers to zero -- which, in a pointer context translates to a null pointer. So, you have to pointers to nothing.
sommeTableau(tableau, tailleTab, &x, &average);

Here, you're passing the addresses of those pointers to the function, so the function is really receiving an int **.
printf("The average is %d\n", average);

This is then taking the value of the pointer -- the address its holding -- and (probably) treating that bit pattern as an int. This is technically undefined behavior, but on many machines, a pointer it enough like an int for it to appear to work. The same will almost never be true with a floating point number though.
What you want to do here is define two ints (or two doubles) and pass their addresses to your function:
double x=0.0, average=0.0;

sommeTableau(tableau, tailleTab, &x, &average);

// ...
printf("%f, %f\n", x, average);

Answer: It doesn't actually work.
Here you define x and average as NULL pointers to int:
int *x = 0;
int *average = 0;

And here instead of pointers to int you pass pointers to pointers to int:
sommeTableau(tableau, tailleTab, &x, &average);

Which is clearly wrong. You should enable compiler warnings to see such problematic places and correct them.
Here the correction would be:
int x = 0;
int average = 0;

Now, here:
printf("The average is %d\n", average);

You are lying to printf() about what you're going to give it (an int, because of %d), but you're actually giving it a pointer to int. The above correction fixes this. If you lie to printf() about the type of some parameter, anything can happen. If your compiler is gcc and you enable warnings, you can spot this kind of problems as well.


How to find the size or shape of a DataFrame in PySpark?

Question: I am trying to find out the size/shape of a DataFrame in PySpark. I do not see a single function that can do this.
In Python, I can do this:
data.shape()

Is there a similar function in PySpark? This is my current solution, but I am looking for an element one
row_number = data.count()
column_number = len(data.dtypes)

The computation of the number of columns is not ideal...
Comment: You mean `data.shape` for NumPy and Pandas? `shape` is not a function.
Comment: Put this in a function ?
Comment: What is not ideal? I am not sure what else you would like to accomplish than what you already have (except for replacing data.dtypes with data.columns, but it makes little difference).
Answer: You can get its shape with:
print((df.count(), len(df.columns)))

Comment: Why doesn't Pyspark Dataframe simply store the shape values like pandas dataframe does with `.shape`? Having to call count seems incredibly resource-intensive for such a common and simple operation.
Comment: @THISUSERNEEDSHELP I suspect it is because Pyspark DFs are lazy and do not do operations like filter() and flatMap() immediately, and these operations change the shape of the dataframe in an unpredictable way. It could be made cached for operations that do not change the number of rows, but this would give an inconsistent API and cost some extra engineering effort.
Comment: Will this work fine for larger datasets spread across nodes?
Answer: Use df.count() to get the number of rows.
Answer: Add this to the your code:
import pyspark
def spark_shape(self):
    return (self.count(), len(self.columns))
pyspark.sql.dataframe.DataFrame.shape = spark_shape

Then you can do
>>> df.shape()
(10000, 10)

But just remind you that .count() can be very slow for very large table that has not been persisted.
Comment: I really think it's a bad idea to change the DataFrame API, without a valid reason to do so. just call `spark_shape(my_df)`... Moreover, possibly name the function something clearer like `compute_dataframe_shape`...
Comment: This tip is for data scientists or data analysts who have to constantly type those command every day multiple times when they do analysis on data. It is not for better engineering perspective or production code.
Answer: print((df.count(), len(df.columns)))

is easier for smaller datasets.
However if the dataset is huge, an alternative approach would be to use pandas and arrows to convert the dataframe to pandas df and call shape
spark.conf.set("spark.sql.execution.arrow.enabled", "true")
spark.conf.set("spark.sql.crossJoin.enabled", "true")
print(df.toPandas().shape)

Comment: Isn't .toPandas an action?
Meaning: isn't this going to collect the data to your master, and then call shape on it?
If so, it would be inadvisable to do that, unless you're sure it's going to fit in master's memory.
Comment: If the dataset is huge, collecting to Pandas is exactly what you do NOT want to do. Btw: Why do you enable cross join for this? And does the arrow configuration help collecting to pandas?
Answer: I think there is not similar function like data.shape in Spark. But I will use len(data.columns) rather than len(data.dtypes)
Comment: that just gives you number of columns. What about number of rows?


Converting Data to a Dictionary From a CSV Without The First Row

Question: Suppose I have a CSV file that looks like the following:
Title,Category,Price,Rating
To Kill a Mockingbird,Fiction,11.99,89
Killing Lincoln,Nonfiction,15.99,85

And I want to convert it into a dictionary that looks like the following:
{'To Kill a Mockingbird': ('Fiction', 11.99, 89), 'Killing Lincoln': ('Nonfiction', 15.99, 85), ... }
I want to make sure the titles of the columns are removed (i.e., the first row is NOT included).
I started by trying the following.
import csv
reader = csv.reader(open('bookdata.csv'))
result = {}

for row in reader:
    key = reader[0]
    result[key] = reader[1:]
print(result)

But when I do this, I don't successfully remove the first row, and the dictionary contains lists, not tuples. How can I fix this? I also want to make sure the \n character is stripped.
Comment: are those in different columns the csv or all in the same column separated by a comma?
Answer: You are close. First, there is a bug where you say reader when it should be row. Then its just a question of skipping the header line with next and converting a list to a tuple.
import csv
from decimal import Decimal

reader = csv.reader(open('bookdata.csv'))
# skip header
next(reader)
result = {}

for row in reader:
    # only needed if empty lines in input
    if not row:
        continue
    key = row[0]
    # Book with category, price in decimal, and other thingie??
    result[key] = row[1], Decimal(row[2]), int(row[3])

print(result)

Comment: is it possible to cast the numeric values as ints and floats during this process?
Comment: @324 - updated. I used `Decimal` instead of `float` because it looks like a dollar price and binary float is only an estimate of a decimal number. You can change that to float if you prefer, but there may be some loss in accuracy.
Comment: I tried this @tdelaney and it is still not working :( ```  books = {'To Kill a Mockingbird': ('Fiction', '11.99', '89'), 'Killing Lincoln': ('Nonfiction', '15.99', '85')}
from decimal import Decimal

for row in books:
    # only needed if empty lines in input
    if not row:
        continue
    key = row[0]
    # Book with category, price in decimal, and other thingie??
    books[key] = row[1], Decimal(row[2]), int(row[3])

print(books)   ```
Comment: I tried putting float instead and that didn't work either.


Ice Dispenser auger won't stop dumping ice into chute

Question: I have a 9 yr old Kenmore side by side fridge (Model #25355699407).  The external ice/water dispenser panel leaked for years, eventually bubbling out the exterior paint, and rusting the door.  I removed the ice/water dispenser panel to refinish the door, which involved disconnecting the ribbon cable which connects the Dispenser power board to the Dispenser Control board.  Now, when I re-connect those with the ribbon cable and plug in the fridge, the ice dispenser auger immediately starts dumping ice into the external chute and won't stop.
I've tried/tested:

Replacing the ribbon cable - same result
Testing/replacing the micro-switches - same result

My next steps are to replace the Dispenser Power Board or Dispenser Control Board, but as these two parts run around $150 EACH, I'd like to know if anyone has any advice, specifically regarding:

How to figure out which of the two boards may have failed
If I start with one board, and choose the wrong one, am I at risk of damaging the other?
Is there any other part, inside the ice maker itself, which may have failed? I'm a little unclear about how the dispenser controls "talk" to the auger.

At this point, it is actually just about as expensive to buy a whole new door as to replace both circuit boards, which leaves me pretty frustrated.
Additional curious note:
The last time I put everything back together and connected the ribbon cable, with the refrigerator still unplugged (and had been for at least 15 minutes), I saw a flash behind the Dispenser Power Board.
Comment: No - as soon as I unplug the ribbon cable, it stops - but of course then I can't get either water or ice thru the door.
Comment: Yup, that's the one
Comment: working on it...
Comment: I'm going to log in with my husband's account - he has more reputation, so can post pictures and chat - (he's here with me now) - I'm confused about instructions
Comment: Does it make sense to switch to Chat ? (although I've not used it on StackExchange before)
Answer: Short Answer:  Replaced both boards, and this fixed it.
Despite lots of excellent help from others on this forum, concluded that I couldn't adequately test the boards without risking damage to a new board by connecting it to one of my current (status unknown) boards.  Very appreciative of the caution regarding these parts' sensitivity to static discharge, as even the chat help person from the parts website didn't know about this (but the parts packaging confirmed that you need to wear a wrist strap grounding device and handle carefully to avoid damaging the new parts).


Automate PyDev Interpreter setup

Question: I have a scenario where I want to be able automate the setting up of various Python interpreters for use in PyDev.  These interpreters have special environment variables, forced built-ins and libraries defined.  Is there a way through perhaps an .ini file or through the PyDev / Jython API to programmatically define Python interpreters for PyDev?
Answer: In the Java API it's something as:
IInterpreterManager manager = PydevPlugin.getPythonInterpreterManager(true);
manager.setInfos(exesList, interpreterNamesToRestore, monitor);

The exesList is a list of org.python.pydev.ui.pythonpathconf.InterpreterInfo and the interpreterNamesToRestore a list of the interpreters that were changed (i.e.: should have the pythonpath restored).
You could probably do this from Jython, but PyDev provides no hooks where you'd be able to do that (i.e.: it only provides hooks for setting up an editor), so, the best solution right now would be creating a simple eclipse plugin that had an earlyStartup to do the configuration you want (should be straightforward).
Comment: This solution worked fine for me. I think it's a much better approach than working with plugin customization files as discussed in other answers.
Answer: I had this same question a while back after getting frustrated with Eclipse plug-ins fighting each other and ruining otherwise 'pristine' setups so I dug around and found these nifty tidbits:
Eclipse run-time options (cli options for running what would otherwise be captive-UI features.
Running Eclipse's update manager from the CLI
So, if you read through the run-time options a bit, you'll come across..
eclipse.pluginCustomization {-pluginCustomization}
the file system location of a properties file containing default settings for
plug-in preferences. These default settings override default settings
specified in the primary feature. Relative paths are interpreted relative
to the current working directory for Eclipse itself.

Which will probably do what you want.
Comment: I was also interested in configuring PyDev from the command-line when starting Eclipse. So I once configured PyDev manually (python interpreter, jython interpreter, initial interpreter commands, ...).  Then I used File/Export/General.../Preferences to save these settings, removed anything other than pydev settings from the file, and tried to use that file with the `-pluginCustomization` option. Problem is that only some settings are taken, like the initial interpreter commands for a PyDev console. But the Python and Jython interpreters are not used. Any idea?

Automate PyDev Interpreter setup


Centre of Mass of a Quadrant of a Square from which a Quadrant of a Circle is Cut

Question: The wing of a hang-glider is a uniform lamina, formed by removing from a square of side $l$ a quadrant of a circle of radius $l$, with its centre at one corner of the square. Find the distance of the centre of mass (COM) of the wing from the opposite corner.
Answer should be $0.316l$
Tried finding the COM of the circle quadrant using
$$\frac{2l\sin\alpha}{3\alpha}$$
with $\alpha = \frac{\pi}{4}$ and subtracting from $\sqrt2l$.
How would you do this?
Comment: Right idea, wrong value. The square's CM is not at $\sqrt2l$.
Comment: $\sqrt2l$ was intended to be the length of the diagonal of the square from corner to corner, in this case.
Comment: CM of the square itself would be $\frac{l}{2}$.
Comment: If you're measuring along the diagonal, it's at $\frac{\sqrt2}2l$.
Answer: Hint: You can treat each piece as having its entire mass concentrated at its CM and use the formula for a set of point masses:$$
\mathbf r_{CM}=\frac1M\sum m_i\mathbf r_i.
$$ In this case, that gives $$
m_{\text{square}}\mathbf r_{\text{square}}=m_{\text{sector}}\mathbf r_{\text{sector}}+m_{\text{wing}}\mathbf r_{\text{wing}}.$$ By symmetry, of course, we need only work with distances along the diagonal.
Comment: Thanks for your hint. I worked it out myself a few hours ago in the same way - see my answer below. I took the distances along the diagonal, as well.
Answer: $$l^2 * \frac{\sqrt2l}{2} - \frac{\pi l^2}{4} * \frac{8l}{3\pi \sqrt2} = (1-\frac{\pi}{4})l^2 * x$$
So, on simplifying $$ l^2*\frac{\sqrt2l}{2} - \frac{2l^3}{3 \sqrt2} = (1-\frac{\pi}{4})l^2 * x $$
So COM is $$ x=1.098l$$ from the corner of the quadrant of the circle.
Now from the opposite corner, the distance of the COM is $$\sqrt2 -x = 0.316l$$
$\sqrt2$ being the whole length of the diagonal.


Changes in grub.cfg are ignored

Question: I'm trying to change the default OS in grub, but when I do
sudo gedit /boot/grub/grub.cfg and change it to option 3 instead of 0 and run update-grub, nothing changes. The default selected OS is still the first one and when I look in grub.cfg it's back to 0. What am I doing wrong?
Answer: As stated on the top of /boot/grub/grub.cfg:
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

Edit /etc/default/grub instead.
Here are details on how to configure the grub file; see the other answers there for a GUI-based method.
Answer: For a small change, just save grub.cfg without update-grub afterwards.
Just realize that anything you do will revert to the information in the scripts the next time update-grub is called.
Thus the reason we don't edit grub.cfg directly.
Answer: I forgot about a GRUB installation from source into the /usr/local prefix which was reading /usr/local/etc/default/grub. I removed /usr/local/sbin/grub-mkconfig and reinstalled the system packages  and it works as expected, now.

Changes in grub.cfg are ignored


Dynamic URL in PHP not working when passing "&" in href tag

Question: I have the following URL
http://localhost:8777/business.php?id=Mobiles and Tablets

When I am passing "and" in id it is redirecting me to the desired page but when I am passing
http://localhost:8777/business.php?id=Mobiles & Tablets

& i.e. ampersand in id it is giving 404 error.
My PHP Code is like this:
<a href="business.php?id=<? echo $cat;?>"><? echo $cat;?>

Answer: You have to use urlencode() in your php code.
<a href="business.php?id=<? echo urlencode($cat) ;?>"><? echo $cat;?>

It will generate link like:
http://localhost:8777/business.php?id=Mobiles+%26+Tablets

Space will be converted to +, and & will be converted to %26
Answer: use php urlencode()

This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.

And use urldecode() to decode your encoded argument

Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.


Preflighted request is not working in IIS

Question: I have a web client that consumes web api.
this is my request:
let peticion = {
        attr1: "0000000047",
        attr2: "070101201"
    };
    $.ajax({
        type: "POST",
        url:"http://22.214.171.124:1210/api/Trabajador/ElTrabajadorYaHaSidoRequeridoEnEsteLocal",
        data: JSON.stringify(peticion),
        contentType: "application/json; charset=utf-8",
        crossDomain: true,
        dataType: "json",
        success: function (data, status, jqXHR) {

        },
        error: function (jqXHR, status) {

        }
    }).then(function (respuesta) {

    });

Cors is enabled in the API CONTROLLER, as far i know, that code line enables everything (*) but It is working only for simple request, not for preflighted requests.
 [EnableCors(origins: "*", headers: "*", methods: "*")]

so I get the next two errors:

OPTIONS
http://18.104.22.168:1210/api/Trabajador/ElTrabajadorYaHaSidoRequeridoEnEsteLocal 404 (Not Found)
http://184.108.40.206:1210/api/Trabajador/ElTrabajadorYaHaSidoRequeridoEnEsteLocal: Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:51939' is therefore not allowed
access.

There is not anything forbidden in http verbs in IIS.

Am i missing something? why is the web api not handling preflighted requests?
Comment: You missed the fact that IIS has CORS module, https://learn.microsoft.com/en-us/iis/extensions/cors-module/cors-module-configuration-reference
Comment: still not working, i configured the IIS cors module from webconfig but i get this "Response for preflight does not have HTTP ok status."
Answer: I have just solved it by setting in webconfig
<httpProtocol>
<customHeaders>
  <add name="Access-Control-Allow-Methods" value="*" />
  <add name="Access-Control-Allow-Origin" value="*" />
  <add name="Access-Control-Allow-Headers" value="*" />
</customHeaders>

and removing this line:

Anyway, when I remove those customs headers from the webconfig and I add [EnableCors(origins: "*", headers: "*", methods: "*")] in the Api Controller, I get just one error :

Failed to load http://192.168.1.33:1210/api/Trabajador/ElTrabajadorYaHaSidoRequeridoEnEsteLocal: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:51939' is therefore not allowed access.

I still don't understand what the difference is between enabling cors from the Api controller or from the webconfig
Answer: You may still need to remove the default IIS OPTIONSVerbHandler, then add the OPTIONS verb to appropriate handler(s) to allow the requests to get to your api.
ie your web.config file will need to be edited along the lines of
<system.webServer>
  <handlers>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit"/>
    <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit"/>
    <remove name="ExtensionlessUrlHandler-Integrated-4.0"/>
    <remove name="OPTIONSVerbHandler"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0"/>
    <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0"/>
    <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0"/>
  </handlers>
</system.webServer>

be mindful of what verbs you use and to use the correct aspnet_isapi.dll for you.
Comment: If i enable CORS from webconfig, it works, but if i enable CORS from WebAPi controller, it doesnt work. i don't know why
Comment: I had to add this line `` then it works
Answer: I am using PHP with IIS, and in my case the PHP custom framework was handling the OPTION request but the request was not reaching the PHP script.
Here are some parts of web.config which changed this:
<configuration>
 <system.webServer>
   <httpProtocol>
     <customHeaders>
       <remove name="X-Powered-By" />

       <add name="Access-Control-Allow-Methods" value="GET,PUT,POST,DELETE,OPTIONS" />
       <add name="Access-Control-Allow-Headers" value="Content-Type,app-code,auth-token,myapp-handle-errors-generically" />
     </customHeaders>

so commenting the Access-Control-Allow-Origin, and allowing the OPTIONS to be executed on the PHP script:
    <handlers>
        <remove name="PHP_via_FastCGI" />
        <add name="PHP_via_FastCGI" path="*.php" verb="GET,HEAD,POST,PUT,DELETE,OPTIONS" modules="FastCgiModule" scriptProcessor="C:\Program Files\PHP\v7.0\php-cgi.exe" resourceType="Either" requireAccess="Script" />
    </handlers>
 </system.webServer>