How do I put an integer value into a char array? I want the number 1234 to be in the char array. I can't read it from a prompt

Question: I'm new to C and I was doing okay in my class(online) until the last couple of programs.  They're getting more complicated and I'm not much of a strategist.  But, I'm trying and I'm frustrated.
I've been working on this one for a while (it's past due) and my ulimate goal is to convert a number into words for a paycheck.
What I'm trying to do here is convert the double value to an int and put the int into a char array, so that eventually the "array amount" will read (if pay was $1234.56) 001234.  Then I was thinking that I could do ifs or cases for each position (hundThous = 0, tenThous = 0, Thous = 1, etc..)  to convert it.  I'm getting stuck here, though and need help.
How do I put the value 1234 into the char array?
Also, in the function above, I called "checkWriter(money);" , where money is the double.  Is that correct?  I just want it to call this function to print the converted double to words.
<code>    void checkWriter(double z)
    {
       double v;
       int w, y, cents;
       int b, c, x, length;
       char array[SIZE];
       char amount[SIZE]; /*size = 7, our largest value will be in the hundred thousands*/

       v = 100 * z; /*make z a whole number*/

       w = ((int)v); /*convert z to an integer w*/

       cents = w % 100; /*cents equals the remainder of w/100*/

       y = (w - cents)/100; /*y equals the converted integer minus cents, divided by 100*/

       sprintf(array, "%-6d", y); /* ATTEMPTING TO PUT y INTO array (saw this on google) */
       printf("%s\n\n", array); /* Just wanted to see if it worked.  It didn't.  I got -2big
                                   number.*/

       length = strnlen(array); /*find length of the value in array*/

       array[length] = '\0'; /* affix terminating null character to array */

       b = SIZE - length - 1; /* b is amount of zeroes needed */

       for(c = 0; c < length - 1; c++) { /* loops, plugging zeroes in amount until b=c,
                                            then attaches array to amount */
          if(b == c) {
             amount[c] = '\0';
             strcat(amount, array);
          }
          else {
             amount[c] = '0';
          }
       }

       printf("%s\n\n", amount); /* Checking to see if it worked. Nope.  All zeroes. And
                                    sometimes extra symbols at the end*/

       return;
    }
</code>
Would really appreciate help.  Thank you!!!
Answer: Please, look at this and this articles.
Basically, you convert double to integer with rounding using
<code>(int)double_value;
</code>
and then convert it to char array using
<code>snprintf(arr, length, "%d", your_integer);
</code>


How can I replace these light switches?

Question: I am trying to change a couple of switches which are in the same junction box.  They control the light on my deck and the flood lights on the corners of the house.
I took out the first switch - it had a black wire (1) stuck into a hole in the back of the switch, and another black wire (2) on a screw on the top right of the switch.  (there is another screw on the top left, but no wire connected.) Since the wire in the box is too large to fit into the holes on the back of my new switch, I decided to take wire 1 and attach it to the bottom screw on the new switch, and wire 2 on the top screw of the new switch, since it was on top before.  Then I loosened the second old switch, only to find that wire 2 from the other switch was in a hole in the back of this other switch.  There was another black wire (3) in the other hole in the back, and then yet another black wire(4) on the screw on the top right of the old switch.  Gah! A call to my brother-in-law later, I decided to attach wires 2 and 3 together on the top right screw (he said I could do that??) and then attach wire 4 to the bottom screw.  Breaker back on - no light :(
Does anyone have any idea what i need to do?
Comment: it'd help if you'd draw a picture. the "hole in the back" is almost always an alternate to the screw beside it, allowing easier installation. you should look into how exactly a switch works. finally, i'd recommend buying a non-contact voltage tester; it'll tell you which wire(s) are from the source (prob wire 2) and which are going to the lights.
Comment: A picture is worth 1000 words, but at the very least, describe which wires that go to holes in back go to top and which to bottom. Also, are there any other switches in the house that control these same lights? BTW, most switches do not have screw terminals to accept more than one wire connection per screw. To connect more wires without more terminals, you should connect all the wires together with a wire nut, including a short piece going to the screw terminal.
Comment: Generally, to replace simple single pole switches, connect all wires that went to the top of the old switch to the top of the new switch, regardless if they are to screws or holes. The two connection methods on the same end tie together inside. Do the same for the bottom wires. Hopefully you remember which wires went where.
Comment: All of the wires were black.  I have a non-contact voltage sensor, but I guess that's different from a voltage tester.  I've replaced practically every light in our house over the years, and never had trouble.  The wires are always color coded, so that helps.  After researching how to replace a switch, I assumed that the wires would be colored, but you know what happens when you assume :)  Thanks for all the advice.
Comment: Are there any white wires in the box at all (likely all attached together)?
Answer: First off, your brother-in-law is wrong.  You cannot attach two wires to a single screw terminal (unless it is rated for that, which most switches are not).
Here's what I'm guessing you're dealing with. Remember it's only a guess since I'm not there and you haven't supplied a picture, or drawing.
Lets call the first switch you mentioned S1, and the other S2, then we'll use the numbers you mentioned above as the wire numbers.

Wire 4 that was attached to the screw on S2 might be power from the breaker.
Wire 2 that is connected from S2 to S1, might supply power to S1.
Wire 1 and 3 would then be switched hot wires feeding the lights.

You should also have 3 white wires connected together, and possibly 3 bare or green wires connected together.  The white wires are neutrals, one from the breaker, and one going out to each light. The bare or green wires are equipment ground, and should be connected in a similar way as the neutrals.
If I'm correct, you should connect wire 4 and two lengths of scrap wire (~6" or so) using a twist on wire connector or other approved method.  The scrap pieces of wire; or pigtails, should be made from a similar thickness and type of wire as wire 4. Next, connect one pigtail to each switch. Finally, attach wire 1 to S1 and wire 3 to S2.
Always make sure the power is off, before working on any electrical circuit.  And if you need help, please contact a qualified Electrician.
Also don't forget. I'm not there, and I only have your brief description to go on. So I could be wrong.
Comment: sounds like a good plan to me.  There probably is a hot feed, shared by the two switches, with all the neutrals connected in the back of the box.

How can I replace these light switches?


I installed GUI programs, but no shortcuts were added—how can I execute them?

Question: I installed DeVede and DVD Author. I am clueless on how to use them as there were no shortcuts created, when using Add/Remove programs. Did they not install correctly? What is the name of the programs directory? Do they need to be launched in command line? What is the command to execute or, is there an executable in program folder, that was created in a directory I cannot find?
Answer: You can get a list of all the files that are installed by the package with:
dpkg -L [package-name]

You are looking for executable files, which are placed in bin directories, so you can filter that this way:
dpkg -L [package-name] | grep "bin/"

There may be more than one thing listed, but this should narrow it down enough that you can try them from a GUI terminal until you get the right one.
Comment: Thank you! It showed me they were not installed for some reason. Just tried sudo apt-get install and it's installing now


android automatically accepts self signed certs on wifi

Question: I have a WPA2 Wi-Fi network and currently using self-signed certificates.  My iOS devices request I accept them manually.  My MacBook pro asks as well.  My Android (Samsung), just connects.  Is that normal?  Kind of concerns me it doesn't even warn you.
Answer: While it is frustrating, keep in mind that ultimately a user is being asked to make a security decision. When most users are prompted in Windows, iOS and macOS, they're usually blindly accepting the certificate. Even if the user were to examine the certificate, there is nothing to compare against (unless IT has explicitly told all users what to look for).
If security is top of mind, tunneled EAP methods with password exchange should not be used. In environments where some devices are unmanaged, EAP-TLS is the only safe bet.
Note that Android 7.1 and higher has greatly improved EAP server certificate validation.


What's the common thread between Fargo and Shut Eye?

Question: I started watching Shut Eye on hulu and I realized some actors from the Fargo series on FX are in it, Jeffrey Donovan and Angus Sampson.  I don't believe in coincidences but I can't find a producer or exec that's involved with both shows.
Answer: If you lost your job one day, would it be a coincidence that you started looking for another job the next day?  Would it be a coincidence that your friend whom you've worked with in the past helped you find a new job?
I haven't been watching Fargo or Shut Eye, so I don't know the particulars of these two actors' situations in either show.  The "losing your job" analogy may not be entirely accurate, but I think it makes the point - it's not a coincidence that actors go from one show to another, sometimes in groups.  They can network with other actors or crewmen to find new gigs.  There doesn't need to be an exec in common between two shows for multiple actors who know each other to turn up in multiple shows together.
I've noticed similar goings on with the main cast from Buffy the Vampire Slayer, for example.  Alyson Hannigan (Willow) eventually landed a new role on How I Met Your Mother, and then her former Buffy co-star (and RL husband) Alexis Denisof showed up in a recurring role on HIMOM * as well.  I'm not aware of any major execs in common between the two shows, but they obviously networked among themselves, what with being married and all.
In particular, with the recent trend towards shorter TV seasons (10-ish episodes instead of 22-ish) I've noticed that some actors are taking on larger roles in two or three shows at a time, presumably because the smaller number of episodes means less filming time per season, and therefore more free time to pursue side projects.  So, the fact that Mr Donovan helped Mr Sampson (or vice versa) land a new role may not be indicative of either actor leaving the former show.
* How I Met yOur Mother.  I know it's not the traditional way to make an acronym, but I like this one better than HIMYM.  Related
Comment: snarky but fair
Comment: It was meant to be cheeky, but not offensive.  Hopefully no offense was taken ;)
Comment: no more than the downvotes ;)


Linear mixed effects model with time series

Question: I have been reading through the different posts here on linear mixed effects models, but am still very unsure whether I have understood the task correctly, therefor I am reaching out for help by the community, any point in the right direction will be greatly appreciated!
The task I was given is described as follows:
The mean difference between treatment and placebo in terms of symptoms core values at Day1, Day2, Day3, Day4 will be estimated with a repeated linear mixed
effect model (LMM) with an unstructured covariance matrix. Treatment and time will be used as fixed effects, and baseline symptoms severity as a covariate.
I read that as

Dependent variable: Severity at given time
Fixed effect: Treatment + Timepoint
Covariate: Baseline measure

Example data:
mydata <- data.frame(
  Subject  = c(rep(c("F1", "F2", "F3", "F4"), each=4)),
  Timepoint = c(rep(c("1", "2", "3", "4"), each=4)),
  Treatment = c(rep(c("B", "A", "C", "B"), each = 4)),
  Severity_at_given_time = c(6.472687, 7.017110, 6.200715, 6.613928,6.829968, 7.387583, 7.367293, 8.018853, 7.527408, 6.746739, 7.296910, 6.983360, 6.816621, 6.571689, 5.911261, 6.954988))

And then fitting the model as follows:
severity.model = lmer(Severity_at_given_time ~ Treatment + Timepoint + (1|Baseline_measure), data=my.data)
summary(severity.model)

(In my full data that gives an R2 of 0.02)
Now I have to say I dont understand the part about "repeated LMM", why is that? From talking to the experimentalists they want to know whether there is a significant difference between treatment and placebo over time, which should already be captured by a single LMM?
Many thanks for feedback!
Answer: I think there is some confusion in the name of the model to be fitted, stemming most likely by the procedures name in the software that is used.
If understand correctly, you want to fit a multivariate regression model (aka marginal model) with an unstructured covariance matrix. This can be done, for example, using function gls() from package nlme. In your case, you could use something like:
fm <- gls(Severity ~ Timepoint * Treatment + baseline, data = your_data,
          correlation = corSymm(form = ~ 1 | Subject),
          weights = varIdent(form = ~ 1 | Timepoint))


"Advantage" in the context of animacy

Question: Is it ok to say "my [or his or her] advantages"?  Or should  advantage be used only for non-sentient subjects, for instance, "advantages and disadvantages of a company"?
Comment: I think it's common to say, "Bill's advantages are strength and speed", or "Foobar Corporation's advantages are high volume and access to markets."
Comment: I'm not sure it's really idiomatic to speak of *the advantages of a **company*** either. Usually we speak of the advantages of *[using] **a method*** when we mean *benefits*. If we're talking about the actual attributes of something/someone that are advantageous in some context, we tend to call them *assets, strengths, strong points*.
Comment: thx, it makes sense. And I'll correct a doc using a more natural word.
Comment: It really does depend on the exact context, which you haven't given. But I'm assuming you mean something like *the advantages **of hiring** me* (to a prospective employer), rather than *my advantages **over other candidates** [applying for the same job]*. If the advantage associated with a person is for *someone else's **benefit***, that's probably the best word to use.
Answer: It's OK to speak of practically any entity, animate or inanimate, corporate or individual, physical or mental, as possessing or offering an advantage.
But when you start playing with prepositions you have to be careful.
Keep in mind that five distinct entities are involved when you speak of advantages.

First, there is the Benefactor—the entity which provides the advantage. We usually speak of this with of: the advantage of speed, the advantage of access to markets, the advantage of wealth.

Second, there is the Beneficiary—the entity which enjoys or wields the advantage. We usually speak of this with to: the advantage of speed to a predator, the advantage of access to markets to an enterprise, the advantage of wealth to a student.
Note that either of these first two may be expressed with the genitive: speed's advantage, or the predator's advantage.

Third, there is the Domain—the entity within which the advantage obtains. We usually speak of this with in: the advantage of speed  in hunting, the advantage of access to markets in increasing sales, the advantage of wealth in getting a good education.

And fourth and fifth, there are the Rivals—the entities with respect to which an advantage is asserted. Rivals are of two sorts, rivals to the Benefactors or rivals to the Beneficiaries: either one advantage is superior to others, or one competitor is superior to others by virtue of enjoying that advantage. We usually speak of this with over: the advantage of speed over strength in hunting, the advantage students from rich families have over students from poor families.

"Advantage" in the context of animacy


What is wrong with this question?

Question: What is the problem with my question? I got 2 downvotes already but no explanation as to why. If my question belongs elsewhere, or if the answer is "no", why won't people just tell me?
Answer: It is a bad question for Stack Overflow - it is asking for resources.
Resource questions are considered not constructive.
In general, questions that ask people for opinions (and people will recommend different resources depending on their opinion of them) are not good questions for Stack Overflow.
Answers are expected to be definitive, which such a question makes impossible.
You may find more detail in this question on meta.
Comment: @user1274649 - Well, provided you explain what you have tried already and why that didn't work for you. I suggest reading [Writing the perfect question](http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx) by Jon Skeet.
Comment: But there are plenty of questions where a user asks how to do something specific and the best answer is 2 sentances long and links to a library which "solves it all". Whats with that?
Comment: @user1274649 - The question has a definitive answer. It is not asking for "what library will solve my problem"? It is a "here is my problem, what I have done to solve it. This is not working - what can I do?". Do you see the difference?
Comment: So if I reworded my question to "How can I use JavaScript to connect to Multiple Third Party OAuth2 protocols?" Or is it just an impossible question to ask?
Answer: A question asking for which library/framework to use has exactly the same problems as shopping questions.  Shopping questions are considered "Not constructive" as is described in this blog post.
Comment: @user1274649 Answers that contain only links aren't considered good either.
Comment: But there are plenty of questions where a user asks how to do something specific and the best answer is 2 sentances long and links to a library which "solves it all". Whats with that?
Comment: @user1274649 I don't see the contradiction.  You shouldn't ask specifically for a library and exclude all other solutions, but it's perfectly acceptable to propose using a library as an answer to the question.  (Although, as Mike B has indicated, it needs to be done properly and not just be a link.)  The primary difference here is that other types of answers aren't excluded.

What is wrong with this question?


Constrained kernel density estimation

Question: Suppose you are trying to estimate the joint density $p(x,y)$ based on observed $(X,Y)$.  However, you know that the marginal density $p(x)$ is uniform.  How can you use this information to improve your density estimate?
Comment: homework? See http://stats.stackexchange.com/faq
Comment: Not homework.  This is for the purpose of creating a "conditional density plot" for simulation results.
Comment: It looks like the question is incomplete. What are the ranges of $X$ and $Y$, what about their distribution, i.e., whether they are discrete or continuous or can be anything, about their dependence and what about the marginal distribution of $Y$?
Answer: My answer: I assume $(X,Y)$ is abs cont, i.e. has a density $f_{(X,Y)}$ with respect to Lebesgue measure in $\mathbb{R}^2$. Everything can be done by using parameter "weights" of function density in R, i.e. with a call to
$$\text{density}\left ((Y_1,\dots,Y_n),\; \text{ weights}=(e^{|x-X_i|^2/h^2})_{i=1,\dots,n}\right )$$
to estimate $\hat{f}_{Y}^{|X=x}(y)$ (for a given $x$) and a proper use of conditioning formulae (given at the end of the post (you also need to tune the window parameter $h$).
Developpment: I assume $X\leadsto \mathcal{U}[0,1]$. Since you know $f_{X}$ you only need to estimate $\hat{f}_{Y}^{|X=x}(y)$ the conditional density.
Depending on how much observation you have, there might be different strategies.
The simplest one is to do a regular binning of $[0,1]$, say with $p$ bins and estimate $\hat{f}_{Y}^{|X=x_i}(y)$ ($x_i$ stands for the center of bin $i$)  with an histogram (or with function density of R) for each $i=1,\dots,p$. Your final estimate is
$$ \hat{f}_{(X,Y)}(x,y)=\frac{1}{p}\sum_{i}1(x\in B_i)\hat{f}_{Y}^{|X=x_i}(y)$$
$1(x\in B_i)$ is the indicator function that $x$ is in bin $i$.
Obviously you can turn the zero-one weigthing scheme ($1(x\in B_i)$) into a smoother one (you need to adapt the calculation of $\hat{f}_{Y}^{|X=x_i}(y)$ but it is easy since function "density" of R allows for a parameter "weigths"). Your weights have to keep the invariance by translation which characterize the uniform distribution. For example,  with exponential weight of windows parameter $h>0$ this will give, for a given $x\in [0,1]$, something like:
$$ \hat{f}_{(X,Y)}(x,y)=1(x\in [0,1])\frac{1}{\sqrt{2\pi}h}\int_{t}e^{|x-t|^2/h^2}\hat{f}_{Y}^{|X=x}(y) dt$$
where $\hat{f}_{Y}^{|X=x}(y)$ is obtained with function "density" of R and parameter weights=$(e^{|x-X_i|^2/h^2})_{i=1,\dots,n}$.

Constrained kernel density estimation


What did the Interceptor's Power Battery do to Hal's ring?

Question: In the pilot of Green Lantern: The Animated Series, Hal tried to recharge his battery off the Power Battery that powers the Green Lantern Interceptor.  It seemed to work, but had some odd side effects.  His ring was able to unleash a strangely powerful blast, and it appeared as though his ring was channeling energy from the battery.  Normal Power Batteries just recharge rings, as far as I know.  Have larger batteries ever been shown in the comics to grant rings abnormally powerful capabilities?
Answer: No, not so far as I have seen in reading the series.
Especially during Blackest Night and the War of Light, where the GL Corps were desperate for extra power, they never tried recharging from a bigger battery (though I think they may have charged from the Central Battery at some point, with no difference from charging from their normal batteries).
Interestingly, the Blue Lantern Corps are able to recharge a GL's ring very quickly, and they can charge the ring to well over 100% capacity.  I clearly recall a single (or possibly 2) Blue Lanterns charging dozens of green rings to ~200% power (from below 20% levels).
Even in these cases, the rings simply have more available power (and can thus potentially hit harder), but gain no new abilities, just added stamina during combat.


Safe wiring of a window AC unit

Question: I have a window AC unit rated at 115V 6.8 amps. If I wanted to plug the AC into a wall outlet, how do I determine if the wiring in the wall can safely handle the current. The wall outlet is a 3 prong US outlet and is 120V. However, if it can't be wired to the outlet, what would I need to run wiring 100ft to the connect it to the breaker?
Answer: The minimum for any 115V outlet should be 15A.  But you should be able check that by finding the circuit breaker for that circuit at the panel and checking its current rating.
The problem you'll possibly run into is if there are OTHER high-current devices on that same circuit.  If both that and the AC run at the same time you may get a breaker trip.
Comment: The key takeaway is that if the breaker trips, then the wiring is safe and doing its job! Inconvenient, maybe, but safe.
Answer: A typical US wall receptacle is a 15A receptacle, and is connected to a 15 or 20A circuit breaker. So a little math shows it would use 45% or 33% of a the capacity of a circuit.
This size of load requires some caution. If when the AC cycles it causes brown-outs or trips a breaker you should find another place for the AC. But really you should be fine as long as you don't have a bunch of other high current stuff plugged into that circuit. If you want to be pro-active you could figure out which breaker feeds the receptacle you want to use, turn it off and look at the rated amps on the handle. Then identify the other receptacles connected to that circuit and add up typical amps of connected devices. If devices are listed in watts then calculate 115 watts per amp.
As a general rule if you ever trip a breaker you should identify every thing that stopped working when tripped and redistribute loads to prevent it from happening again, repeated tripping will weaken a breaker and exacerbate the problem.
If you experience tripping and can't redistribute loads (or you are just curious what it would take) 6.8A 100 feet away wouldn't cause excessive voltage loss caused by the wire size, so you would only need a 15A breaker, #14 wire, and a 15A receptacle. Typically you could use 14/2+g (often called Romex) for the wire, but your path for the wire might encounter damp, hazardous, susceptible to damage situations or you might have local ordinances that restrict wiring methods that might rule out NM cable.  It would certainly be acceptable and I would recommend using a 20A breaker, #12 wire, and a 20A or 15A duplex receptacle. It would cost a little more but gives future options.
Comment: @FreeMan, there's an exception in the code that allows 15A receptacles on 20A circuits, as long as there's more than one.  This means that 15A receptacles and appliances need to be designed such that they won't burn up under fault when only protected by a 20A breaker, and UL testing ensures this.
Comment: Can you put a 15a receptacle on a 20a breaker? I thought that if you have a 20a breaker then _everything_ on the circuit had to be rated for 20a (#12 wire & 20a or higher rated receptacles). This would prevent the 15a receptacle from burning before the breaker decided to trip
Comment: @FreeMan  NEC 210.21(B)(1) requires a single receptacle on a branch circuit to be not less than the rating of the branch circuit, 210.(B)(3) and referenced table allows 15A receptacles on 20's and 50's on a 40.    https://i.stack.imgur.com/yfeFM.png
Comment: @NateS. and NSP - thanks, I was unaware of that! Since I'm about to run a 20a breaker and have multiple receptacles for plug in lights, I may just go with 15a receptacles and save a couple of bucks. ;)

Safe wiring of a window AC unit


principal square root and solutions to an equation

Question: The square root or $n^\text{th}$ root (where $n$ is even) of a number can either be $+a$ or $-a$. But for square root for example, to be a function we must define its output either to be positive or negative number because if we can get multiple values from it then it is not a function, right? So, we define the result from taking a square root for example, of a number, to be always a non-negative number. But suppose we have an equation $b^2 - c = 0$. Then, the solutions to this equation are $+\sqrt{c}$ and $-\sqrt{c}$. This means that there are two possible answers for the equation, but we want the function to have a single answer, so we agree that it will be the non-negative one. So, we first get the value from the function which is non-negative number and then we seek for the possible answers for the equation which can be positive or negative. Am i right?
Answer: I would prefer to write some of this as a comment but I'm not allowed to yet so I'll try to answer as best I can.
So you're talking about an even nth-root function, say $f(x) = \sqrt{x}$, right?
Yes it's true that the principal square root is defined as the nonnegative value.
So for instance $f(4) = \sqrt{4} = +2$.
I'm not really sure what it is your asking in the last part though. "So, we first get the value from the function which is non-negative number and then we seek for the possible answers for the equation which can be positive or negative. Am i right?"
This part of your question doesn't make sense without some context. Are you asking about finding the image (range) of the function? Or are you asking a question about solving the equation? If you had a specific problem in mind that might clear things up a bit.
I guess I'll mention that if you wanted to plot the negative values, then you would use the following function:
$$g(x) = -\sqrt{x}$$
(notice the "$-$" in front). Then g would define the negative square roots.
If you're talking about polynomials (equations involving a variable with positive integer exponents), then to find the solutions you would first try to factor everything. In your example $b^2-c = (b-\sqrt{c})(b+\sqrt{c})=0$ which is how you can see that the two roots are $\pm \sqrt{c}$. Since you're question seems to be regarding even-powered binomials then you would always be able to factor it as a difference of squares: $(b^n-c) = (b^{n/2} - \sqrt{c})(b^{n/2} + \sqrt{c})=0$ which would usually be able to be factored further depending on your value for n.
I can explain more if you can clarify what it is you are asking.
Comment: i am talking about solving the equation. My idea is that we define a root function to always give the positive result and when we obtain the result from the function to precede it by a minus and a plus sign because the equation has two solutions.
Comment: I guess you could do it that way (as long as you're only using real numbers and not complex). The only reason I would think to define a function in the first place would be to plug it into a calculator or computer though. So you could use your nth-root button to find the positive answer and then tack on a negative as well if the n is even. But just be aware: if you needed the factorization of the binomial for any powers greater than 2, you wouldn't be able to find it with the function alone.
Comment: I consider taking a root of a number as a function. So you have a number and when you take the root of it you get a new number. I think of this as a function, the first number as input and the new number as the output of the function. So, for taking the root of a number to be a function we must define its output. The output can be a positive or a negative number. We define the root function to output a positive number so we are done with that. Next, to get the solutions of the equation above we "call" the root function and we precede it with + and - sign denoting the two solutions.


What is the etymology of 'slap-bang'.?

Question: I read "slap bang in the middle of the debate".
Comment: Hello, sivacva. Have you done any research yourself?
Comment: etymology is the wrong word for your question. You mean origin.
Answer: It is probably a variant of the apparently older and similar expression smack bang:

The OED points out that the verb "smack" can be used as an adverb to mean "With, or as with, a smack; suddenly and violently; slap. Also with down, through, etc.
The quotations given to illustrate this sense are:
1782 COWPER Smack went the whip, round went the wheels. 1799 GEO. [IV] in Paget Papers He..tumbled..smack on his face. 1806 H. SIDDONS Smack comes a ball from the enemy and carries away his head. 1836 T. HOOK So away I went smack bang into a quaker's shop to buy myself a pair of gloves.
As you can see, by 1836 "smack-bang" already existed, doubling the effect of "smack" on its own. (VSD)
The OED shows also a further development of the adverbial sense, to mean "completely, entirely; directly," and this is the way I usually hear it used - for instance, to be "smack in the middle of something,"  or in the quotations cited:
1828 WHEWELL We have got a decision which is smack against us. 1857 A. MATHEWS The wind being smack in their teeth the greater part of the voyage. 1864 TYTLER [Cardan] made the bishop smack whole in twenty-four hours.
  And these too can be doubled for emphasis, "smack-bang." - Baceseras.

(Phrase Finder)
Answer: Lexicallab.com in its 'Phrase of the day' – 'slap bang in the middle',  says in a rather defeatist way '[The origins are] anybody's guess'.
But there is quite a lot of evidence available.
Grose's Classical Dictionary of the Vulgar Tongue: Revised and Corrected – 1823 gives a reasonably early usage, as onomatopoeic noun and attributive:

Slap-bang Shop. A petty cook's shop, where there is no credit given, but what is had must be paid for down with the ready slap-bang,
  i. e. immediately. This is a common appellation for a night-cellar
  frequented by thieves, and sometimes for a stage-coach or caravan.

Slang: A Dictionary of the Turf, the Ring, the Pit, Or Bon-ton ... by John Bee – 1823 (the whole title [slightly modified here] is worth reading!) contains the more obvious literal sense:

Slap-bang: a blow from each hand. See one-two.

'The old one-two' is still a well known phrase, and there is the more modern 'double whammy'. The modern emphasiser / interjection 'bom-bom' is similar in most respects, but hasn't the same distribution (*'bom-bom in the middle').
The Comic Almanack: An Ephemeris in Jest and Earnest – C Tilt, 1840 (though it seems to be quoting Thackeray in his 'History of the next French Revolution') shows an earlyish usage that is (probably!) adverbial. This may show a transition to what I'm labelling the prepositional-phrase-modifier usage we know today.

[... helter skelter], skurry hurry, slap bang, whooping, screeching,
  and hurraing, blue coats and red coats, bays and greys, horses, dogs,
  donkeys, butchers, baroknights, dustmen, and blackguard boys, go
  tearing, all together, over the common after two or three of the pack
  that yowl loudest. Why all this is, I can't say ....
Comment: I have heard 'smack dab', although I think it is a little old-fashioned, and possibly mainly British.
Comment: @Edwin Ashworth Good stuff. By the way, Grose's example seems to contain a misprint: "a petty crook's shop" seems more likely than "petty cook's", don't you think? (Oh - and the link to John Bee goes to Grose again.)
Comment: @MichaelHarvey Yes 'smack dab' sounds like what I would use, more so than 'slap bang'. But coincidentally I just heard someone on TV with a Caribbean accent use 'slap bang' [Death in Paradise E8S8](https://www.springfieldspringfield.co.uk/view_episode_scripts.php?tv-show=death-in-paradise-2011&episode=s08e08)

What is the etymology of 'slap-bang'.?


Invocable Method to return External Service data type

Question: Ideally, we will create an External Service based on the API Schema and use it in Flows.
For some reason, when we do callouts in the Flow, the API cannot parse the Authorization header correctly, returning us a 403. However, when we do the same callout in Apex using setHeader, the API can correctly read the Authorization header.
Our requirement is that we have to use Flows, but since we are having issues I am experimenting with a workaround, which is as follows:

Create External Credential / Named Credential
Create External Service
Create a Flow
In the flow, create an Apex-Defined Data Type of a External Service Dynamic Apex Datatype
Create Apex class which has Invocable Method to be accessed from Flow
Call the API using Apex (HttpRequest)
Deserialize the response body JSON into the already created External Service Schema
Return the deserialized JSON back to the Flow
Returned data is stored in the variable of Apex-Defined Data Type from step 4

The Apex code is somewhat along the lines of:
public with sharing class GTW_getAllAccountWebinars
{
    @InvocableMethod(label='Get All Webinars')
    public static List<ExternalService.GTWExternalService2_ReportingWebinarsResponse> getAllWebinars(List<String> bearerToken)
    {
        HttpRequest request = new HttpRequest();
        request.setEndpoint('callout: GTW_Named_Credential');
        request.setMethod('GET');
        request.setHeader('Authorization', 'Bearer ' + bearerToken);
        HttpResponse response = new Http().send(request);

        ExternalService.GTWExternalService2_ReportingWebinarsResponse APIresponse = (ExternalService.GTWExternalService2_ReportingWebinarsResponse)System.JSON.deserialize(response.getBody(), ExternalService.GTWExternalService2_ReportingWebinarsResponse.class);
        List<ExternalService.GTWExternalService2_ReportingWebinarsResponse> responseBody = new List<ExternalService.GTWExternalService2_ReportingWebinarsResponse>();
        responseBody.add(APIresponse);
        return(responseBody);
    }
}

So the data returned from GTW_getAllAccountWebinars class is being sent back to the Flow for further processing.
However, the issue I am facing is that the Apex class is returning the following error:
InvocableMethod methods do not support return type of List<ExternalService.GTWExternalService2_ReportingWebinarsResponse>

I am aware that we have to implement wrapper classes to return custom data types, but I don't want to write the entire schema manually using wrapper classes, when I have the schema already created dynamically using External Services.
Hence, my question is how can I return External Service data type from an Invocable Method?
Answer: You can't return it because the Apex Object doesn't have the necessary @AuraEnabled annotation and it's an inner class.
Only outer classes with variables annotated with @AuraEnabled can be used.
You will need to create a Class to hold the relevant variables and return that instead, you can put them in your GTW_getAllAccountWebinars class, or you can create a totally separate class if you want to.
Checkout this it should give you a bit more info.


Which observer can detect the Gravitational Time Dilation?

Question: We say clocks tick slowly in the strong gravitational fields. Is this stated from the perspective view of the one located in a weaker field or the one who is standing in that strong gravitational field? In Special Relativity the time dilation of clocks is said from the view of observers constrained to the other inertial frames and no observer can judge the rate of clock ticks in his own inertial frame.
Comment: the view "clocks tick slowly in the strong gravitational fields" is true only in special cases, like our solar system. But in GR such claim might not even make any sense, f.e. you cannot compare clocks outside of black hole with clocks inside.
Comment: @Umaxo You  may not be able to compare clocks outside of black hole with clocks inside, but you can certainly compare clocks at different distances from a black hole.
Comment: @D.Halsey if those distances are bound to be outside of event horizon. I am also not sure how would it work with rotating black hole - wheter the frame dragging still allows some kind of reasonable and objective comparison... Anyway,  as i said, you can compare clocks in special cases, I just wanted to clarify that such statement is not general.
Answer: If I've understood correctly, there is by definition nothing an observer can say about the "slowness" of their own clock. Therefore all statements about an observers clock slowing down must be relative to another observer who is not in a similar situation. In this case it means that when an observer without a gravitational field observes a clock in a strong gravitational field, they find that the clock is ticking more slowly. An observer right next to the clock never sees any slow down. More informally this can be thought to be because the observer itself is also slowed down. EDIT: As it occurs in the comments, the last sentence is not a good way go thinking about things, as it would imply an observer slowing down compared to some global clock. While this can be the case in gravitation induced slowing, the mind set cannot be applied in moving inertial frames.
Comment: just to clarify - "More informally this can be thought to be because the observer itself is also slowed down." in STR such statement is wrong, due to relativity principle.
Comment: Although I understand that that sentence is not very scientific or nice way to think about the matter, but can you elaborate why is it wrong? Do you mean because I should not draw a distinction between an observer and the clock at the same point, or what is your point?
Comment: when you have two inertial observers moving with respect to each other, then both can claim that the other is slowed down and both views are equally valid. Your sentence tries to give some objective meaning to slowness, which can be made in GR for certain type of gravitational fields, but not in STR, no matter how informal you are trying to be.
Comment: Well yes, you are actually right! Thank you for the explanation, I think I'll edit a note into the answer based on this.
Answer: In general, a Schwarzschild observer, who is away from the effects of the gravitational field, deduces that time dilates for the clocks inside a G-field. Although any other observers located at distances greater from the G-mass than the clock can detect different time dilations considering their distances from the G-mass and from the clock, a Schwarzschild observer is a more formal one.


How could a beechcraft fly such a long distance in LOST?

Question: We know that the beechcraft in LOST TV series took off in Nigeria in west Africa.
So how could it fly across Africa, then fly again over the Indian ocean to crash in the LOST island? (By beechcraft I mean the plane with which Mr Eko's brother took off in Nigeria )
Comment: The Island was in the South Pacific Ocean at the time. A big distance, but your flight path doesn't reflect the location properly. The Indian ocean is on the other side of Africa, not the Pacific.
Comment: @phantom42 It's a craft with an 850 mile max flight and a nearly 8000 mile distance. I have the distinct feeling that it was another case of "the island teleports around because reasons".
Comment: Yeah you're right about the estimated position of the island. So we both agree on the long distance!
Comment: aircraft, including beechcraft also have this amazing ability to land and refuel.
Answer: Short Answer: It couldn't, not without refueling or some supernatural agency at work.
The max range of the Beech 18 is 1650 nm. (Use Beechcraft 350 for reference --1525 nm range).,  meaning if it took off in Lagos, it would need to refuel at the latest in DR Congo, well short of the Indian ocean.

Judging from the map found on the Beechcraft in "Deus Ex Machina" the plane may have been headed towards Inedbirenne Airport in Algeria (24 17' 31" N, 9 27' 08" E) which is roughly halfway between Nigeria and Tunisia, where the Polar Bear John and Ben was transported.
Tunisia is a logical destination for drug smugglers, since it provides easy access to European ports. Also, Tunisia's former president, Zine El Abidine Ben Ali, was long rumored to be involved in the drug trade.

Unless the island magically moved, it never would have reached it, not without refueling. Africa is a very big place.
Comment: This is the interesting point! So there might be something in the wind!
Answer: It's not that simple. Let's say the craft headed towards Tunisia from Nigeria. We all know the Island exit was in Tunisia. Kinda like there is a wormhole connecting b/w them. Once the plane is in the region of Tunisia, a wormhole portal could open up and transport the plane to the Island's vicinity, whereby the Island's magnetic field could do the job.
One more interesting thing is the arrival of Egyptians on the Island. Same reason. Egypt to Tunisia isn't far. Egyptians doing their own research there, found something like MIB found the orchid in 'Across the Sea'. That would transport the Egyptians to the Island.


QGIS Print Composer producing angled graticule lines that look like rectangles instead of squares?

Question: I just tried to create an extremely simple map made of one layer loaded as WMS layer from Croatia's geoportal (http://geoportal.dgu.hr/wms). I successfully loaded the necessary layer and created everything in Print Composer but I have a problem with the graticule - the grid lines are angled and look like rectangles instead of squares?
Comment: The root problem is that a square on the (curved) surface of the earth is not necessarily square when projected flat to a map. The amount of distortion depends on what projection you're using and where in the world you are. The farther away from the equator you are, the greater the difference in meters of what one degree of latitude vs one degree of longitude is. The angle is related to this and what 'north' means.
Answer: The CRS layer that you loaded in QGIS is WGS84 (geographic system) and you are setting a grid interval in meters, try to enable 'on the fly' CRS transformation and setting a proper projected CRS (i.e EPSG:32633). Take a look at Project properties dialog to do it:


Do physics graduate programs recalculate undergraduate GPA's for admissions?

Question: Do physics graduate programs recalculate undergraduate GPA's for admissions?
This is quite common among medical schools but I would like to know if this is a common practice by natural science graduate programs. I have searched quite a few resources online and haven't found a conclusive answer. To clarify my question, recalculation means including EVERY course taken, even the first attempt of courses retaken for a higher grade (because of a grade of D- or lower when taken the first time).
Answer: I would guess that, independent of field, most places do some recalculation, even if informally. Some people/committees just put more emphasis on some things than others.
There is also the situation that grading systems vary widely, especially if there are international students involved.
However, if you have a specific worry that you took a course and did poorly, but then later re-took it and did fine, then that may show up, but it may not be the devastating issue that you fear. It might raise questions, but such things occur often enough that you aren't unique. You may need to explain the situation adequately and indicate that in spite of past problems you are a good candidate and likely to be successful.
There can be a lot of reasons for a bad grade. But most people will look at the entire record, not just something that is anomalous.
The only exception might be if the institution has so many applicants that it has to use crude measures, such as GPA cutoffs, to get the pool down to a manageable number.


Can I reset a conversation in Mass effect 2

Question: so I was doing a second play through of Mass effect, and since this was going to be fem shep renegade, I was dead set on romancing Garrus, but I botched the conversation that led to that romance and didn't realize this until about 7 hours of gameplay later. is there a way to reset the conversation you have with Garrus after his loyalty mission through the binary files or something of that nature so that I don't have to sink another 35 hours into ME2 to fix this.
Comment: save editor is your friend
Answer: No, unfortunately there is no way of doing that besides reloading a previous save. There are cheats that allow you to quick-save before a conversation, but there's little you can do after the conversation has occurred.
Alternatively, you may edit the 'binary files' with a save editor. However, the tables for ME2 doesn't seem to be as clear as for ME3, so while there might not be a way to reset a specific conversation, you can directly edit the romanced or alive/dead values. Just follow this pastebin (and maybe this thread too) that shows you exactly which values you need to edit with the save editor.
Comment: More like, in that page full of tweaks, there's a _tip_ to _quick-save before any conversation_.


Add cart in the commerce cloud test class : ConnectApi methods are not supported in data siloed tests

Question: If we use ConnectApi.CommerceCart.addItemToCart , exception occured : System.UnsupportedOperationException: ConnectApi methods are not supported in data siloed tests. Which method or class to use to create cartItem to webCart.
Answer: Happy new year!

Most Connect in Apex methods require access to real organization data, and fail unless used in test methods marked @IsTest(SeeAllData=true).

ConnectApi CommerceCart requires access to real org data. In our project, we prepopulate / seed test data per environment for the methods which interacts with ConnectApi Commerce functionalities (entitlements, catalog, buyer groups / accounts) for testing these methods or you can use the real org data in your environment right now.
Once setup is complete, we query for those items along with @IsTest(SeeAllData=true) annotation
<code>/*
 * Your test cart class here...
 *
 * NOTE:
 * ConnectApi Methods are not supperted in data siloed tests. Please use @IsTest(SeeAllData=true)
 * Test class containing a test setup method cannot have any methods annotated with @IsTest(SeeAllData=true)
 */
@IsTest(SeeAllData=true)
public with sharing class YourWebcartClassTest {
    @IsTest
    private static void testYourMethod(String productId, Integer quantityAdded) {
        // Query for the user org data with the right entitlements, associated to the buyer groups / accounts
        User entitledUser = [...];

        // Query for the product org data to be added.
        Product2 correctProduct = [...];

        // Product Quantity for demo purposes
        Integer productQuantity = 5;

        System.runAs(entitledUser) {
            // Assuming your addToCart method has two params (productId and quantity which is required in the ConnectApi.CommerceCart.addItemToCart method)
            myCartServiceClass.addToCartMethod(correctProduct.Id, productQuantity);

            // Perform Assertions here..
        }
    }
}
</code>
Answer: This is unfortunately another case when Salesforce product team does not follow their own guidelines. SeeAllData=true should be a last resort. Especially that you might want to create a package which uses ConnectApi and then you cannot reliably expect to know the setup of the target org.
One possible approach:
In our ISV packages we use Test.isRunningTest() to skip ConnectApi callouts, but it truly hinders the purpose of unit tests. Also we are yet to pass security review.
I also remember that we had trouble to setup all kinds of data related to Lightning B2B. For example the creation of a Product2 with ProductClass = 'VariationParent' was impossible in api 50.0. Not sure of current state.


Extrude in curves

Question: Inside Curve Properties there's a Extrude option that creates faces along a curve. When use free handles to make a sharp angle the faces around the free handles have ununified shape like shown below. I find the same problem in Solidify modifier that with Even Thickness off the shape around the sharp angle looks bad and with Even Thickness on it looks good. It's because without even thickness each vertex will extrude the same distance whereas sometimes some vertex(for instance the vertex that forms a sharp angle) needs to extrude longer to make the overall shape unified. So is there a way to achieve the same result for curves like even thickness in Solidify?
Answer: I think that is blender limitation, but there is another way to achive that
you can extrude in curve property as thin as possible,

then add Solidify modifier and check even thickness, you may add Weld modifier to keep one side surface in case you dont need double sided (solidified surface),

Here the result
Comment: Thank you, this works like a charm, in my case I need to set the curve points 90 degrees tilt. The only pity is that the Bevel-Depth of curve properties no longer works correctly with it since the curve has a Solidify modifier. But it's already very good, thank you very much.
Comment: Hi, if i understand you may add solidify again after weld modifier and then add bevel modifier i think it will get similar result.
also, if this answer you looking for, please consider to mark answer accepted
Comment: Yes, with a bevel modifier it would have similar result and thank you again for your kind help

Extrude in curves


TCP timestamps: available to whom?

Question: I was told that an adversary can figure out system uptime by looking at TCP timestamps. But I'm not sure who exactly can see this information. For example, if I set up a hardware Tor gateway so that all network traffic from my computer goes through Tor, and browse SE website normally using the computer, will my ISP know my system's uptime? Will SE website know? What about the local network administrator?
Comment: Operating systems can change their implementation of tcp timestamps to avoid the extraction of the uptime . For linux see my answer https://security.stackexchange.com/a/224696/90485
Answer: TCP timestamps are only visible at the endpoints of the specific TCP connection and on every hop in between. If you are setting up a "hardware" Tor gateway (i.e. some software running on some gateway system) the TCP connection from your systems ends at this gateway. Who can then view the TCP timestamps depends on where this gateway is located. But if it is located inside your local network your ISP will not be able to see the TCP timestamps from your system. He might be able to see the TCP timestamps from your Tor gateway though.
Comment: Even if you run Tor on your own computer, the endpoint does not see the TCP timestamps of your own system. The TCP connection from your computer ends at the guard node.

TCP timestamps: available to whom?


Change TimeZone dynamically in laravel

Question: In my project there is drop-down of time zones(PT,CST etc), when Admin changes the timezone from drop-down the admin panel reflects the timezone from the selected drop down.
How to change Config/app.php "timezone"( Application Timezone) according to the selected option.
Answer: you need also call  date_default_timezone_set
    config(['app.timezone' => $timezone]);
    date_default_timezone_set($timezone);

Comment: You may want to add `\Log::setTimezone(new \DateTimeZone('UTC'));` to the `boot()` method of your `AppServiceProvider` to ensure the your logs are still in UTC time.
Answer: You can use Laravel helper function config to set timezone. However, this will affects only the request you will receive.
config(['app.timezone' => $timezone]);

If your goal is to change once the timezone and run on every request then what about saving the changed timezone in DB or in a file. Then, write a query for DB or read a file in app/config.php and change the value of index timezone in a file.
For example (file example):
When you changed the timezone it saves in a file.
file_put_contents("path/to/file", $timezone);

And, in app/config.php
$timezone= file_get_contents("path/to/file");
return [
 . . .
    'timezone' => $timezone,
 . . .
]

Comment: Whenever there is change in config file, need to run php artisan config:cache to get the changes.
How the changes reflect without config:cache command?
Comment: I don't think so.... did you try? but anyway you can add exec("php artisan cache:clear") that execute random time.. or just once when the file has changed. you can use also filemtime() function. something like this now()-filemtime() < 5, then run exec command
Answer: If you want to keep a new time zone for all future requests, you need to use a package like larapack/config-writer to be able to save the time zone to the app config file.
Another way to handle this is to keep time zone in DB, fetch it in every request and set it with config(['app.timezone' => $timezone]) dynamically.
Answer: You can use middleware to achieve this, whichever routes you will write mention all those applying with that middleware.
You can fetch that data from database and apply it like as follows,
config('app.timezone', 'your selected timezone')

Answer: You can use service provider.
That way, you first need to get the settings information from the database and then change the settings inside the config file.
Config::set('app.timezone', $db['timezone'] ?? config('app.timezone'));

Answer: In AppServiceProvider boot()
$settings = Settings::first();
date_default_timezone_set($settings->timezone ? $settings->timezone : config('app.timezone'));

This overrides default TZ value in app.php

Change TimeZone dynamically in laravel


Product Image Names

Question: I am in the process of migrating from Zen Cart to Magento. In Zen Cart my product images were sorted into folders by Category name..I have read that Magento stores product images according to the first and second characters of the file name but as all of my images start with IMG_, is this a problem performance-wise? Or would it be better to keep the folder structure according to Category name?
Answer: There will be no real performance benefit from renaming images. One of the times where the size of a folder can hinder PHP performance is if you are calling functions such as scandir etc that get a list of all contents within a folder. On large thousands+ folders this can be slow and improved using RecoursiveItterators as an example.
As Magento is not scanning directories for images to load instead loading by filename you will be safe to remain with the current implementation you have. Until it comes time to revisit the images and you are hunting for the blue t-shirt that is named _IMG_SOME_RANDOM_NAME_ :)

Product Image Names


When to do the dishes- Yom Tov starting at Motzei Shabbat

Question: Passover brings an interesting quandry this year- we go through a great many Kosher for Passover dishes at the Lail Pesach seder on Friday night, and then have a couple of meals on Saturday.
 Given that A) it is forbidden to prepare for a weekday on Shabbat, B) it is forbidden to prepare for the second day of Yom Tov on the first day of Yom Tov, C) handwashing dishes is pretty universally prohibited on Shabbat and Yom Tov except for immediate use and D)the second seder should begin at Sundown on Saturday night and requires a clean, set table- assuming one doesn't have unlimited quantities of Kosher for Passover dishes-
when would one be halachically permitted to was the dishes so as to prepare for the second seder?
Comment: How is this different from any other year's Passover? I'm not sure what Shabbat has to do with this at all.
Comment: I'm afraid to say we have always waited until Shabbos has gone out.
Comment: You've already answered the question - you need to wait for Motzai Shabbat. What are you asking?
Comment: @DannySchoemann "the second seder should begin at Sundown on Saturday night and requires a clean, set table" -- maybe that's incorrect?
Comment: How would you feel if a friend came over on Shabbat afternoon and you had nary a clean dish in the house to offer him a cup of tea and slice of honey cake? You could prepare for that eventuality by doing some dishes after lunch perhaps.
Answer: You're definitely not the only one in this "quandary". First of all, I believe that there is some leniency that allows washing dirty dishes if the dirt is either "offensive" or one is troubled by seeing the dirty dishes lying around. I have to research this, but, from what I recall the decisive factors are not as simple as you would think, since, there is always that element of hachanah (preparation) for the next day.
So, I'll address the more "practical":
Most people that I know that use "real" plates deal with this. Preparations begin only once the 2nd day of Yom Tov begins. This is not as terrible as it seems, actually. In most cases, the men are still in shul, because many shuls aren't starting Ma'ariv until exactly when Yom Tov II starts. Even the places that do start a bit early - by the time you say Halle and get sefirah in at the right time and walk home, it's about 30 minutes after the 2nd day has begun. That should allow plenty of time to rinse dishes and set the table. If you have a "large staff" of helpers at home (large family plus some guests), it can be done fairly easily.
If you're really concerned, though - Either have two sets of plates around or better, as I have done numerous years, paper and plastic really help out for this situation and there's nothing to wash afterwards. Trust me from personal experience. I spent numerous Pesach Seders staying up until 2 - 3 AM washing dishes and putting away food. (Incidentally, at night, it's not a problem to wash the dishes that I will be using for lunch the next day.)

Mo'adim Lesimcha to all...
I discovered this article which mentions a leniency. So, while the seder(im) are over, these rules would apply to any Shabbat or Yom Tov.
If the dishes are required for use on Shabbos, it is permitted to wash them.
According to some authorities it is permitted to wash dishes even for the purpose of having the house and kitchen clean and tidy.
Dishes must not be washed with sponges that involve a concern of squeezing out water. Synthetic (non-absorbent) material can be used, or just use your hands. It is permitted to use detergent.
Best wishes.
Sources:
The Shulchan Aruch (OC 323:6) and the Mishnah Berurah (323:26) write that it is prohibited to wash dishes if they are not required for used on Shabbos. However, if the household norm is for the sink to always be clear of dishes, and the sink being full of dishes is seen as clashing with the honor of Shabbos (or Yom Tov), then it is permitted to wash the dishes.
The source for this leniency is Rashi (Shabbos117b), who writes that the prohibition of washing dishes is on account of preparation for weekdays. This implies that if the washing is not for preparation for weekdays, the act would be permitted. [There is certain debate about the position of Rambam in this matter.] The Maharshag, Orach Chaim, Vol. I, no. 61, writes explicitly that this is the case, and permits washing dishes for the sake of hygiene and cleanliness; Tzitz Eliezer, Vol. 14, no. 37 concurs with the ruling.
Comment: Indeed that's why king husband should pitch in and help. The Seder is a Mitzva not busywork. Great Sages make extra effort to be involved in Seder mechanics personally.
Comment: Id discourage using plastic at the Seder. What kind of King has his wine poured for him into a Dixie cup? If you don't have enough real dishes use plastic at lunch
Comment: I was at a community seder once where they had really nice cups for the wine -- at a distance they looked like silver kiddush cups, and only close-up was it clear that they were fancy molded plastic.  if you need to use disposables, you can do way better than Dixie cups.
Comment: @DoubleAA I agree with your concept. But, practically speaking, a truly benevolent king also understands that his queen has already slaved preparing the Seder meal, and there's no need to have her slave over washing dishes.
Comment: In the end @DanF was spot-on- seder guests are more than capable of pitching in
Comment: Also depending on the level of experience at the Seder, most Nirtza songs can be sung while working in the kitchen. (Theyre not really an essential part of the Seder.)
Comment: To add to @DoubleAA's point, Pesachim 7:13 implies that the person serving at the seder is likely to be a man (or at least more likely to be than someone taking challah or bringing a pair of bird korbanos).


UITextView horizontal scrolling

Question: I have a UITextView which wrapping words of long text and it have a vertical scrolling functionality.
How can I switch off the word wrap, and switch on the horizontal scrolling with keep the vertical scrolling?
Answer: i have seen this answer in stackoverflow only..
Let's say I want a scrollable width of 600 and a visible width of 250.
The first step is to make the UITextView a wide as the area you want to be scrollable. So what you would have put into contentSize, in this case 600.
Then the right inset is set to the difference between the actual width and the width you wanted. In this case 350.
This way cursor is restrained to the width you need BUT there is text visible to the right of your desired width, after all, the UITextView IS 600 pixels wide.
Now here's where the really hackish bit comes in, don't read on if you're sensitive or have a weak stomach.
Get an image of the user interface to the right where UITextView should end. Insert it into the NIB as an UIImage view and put it back in it's place, making sure that it's on top of the UITextView.
When the view is displayed, the cutout sits on top of the UITextView and hides the text overrun.

UITextView horizontal scrolling


Why are there so many 2-pole circuits/breakers in my house's electrical panel?

Question:
We noticed during our home inspection the main panel has only six general lighting circuits and seven 2-pole circuits/breakers.  There were only two areas where 240V outlets would be used.  Why would they have so many 2-pole breakers?  Is this normal or will it cause any problems/safety issues?
Comment: It is hard to tell with "that" picture!!
Comment: Were the breakers marked? Did you try tuning them off? Did you get a picture of the panel? Did you get a picture of the panel with the cover off? Those two pictures should be included as part of a home inspection.
Comment: @Criggie They're likely rated 120/240 volts, as I believe that's typical of most breakers used in 120/240 volt systems.
Comment: You should really post a photo of the panel.
Comment: Added picture, hard to tell
Comment: Could you please add the unit (V) to your number? On the first read I thought you had 220 of the breakers, which sounds really much.
Comment: These breakers - are they rated for 220V or are they really 220V circuits?  Circuit breakers trip when the current exceeds their trip rating, of 10 amps or 20 amps or whatever they're designed for.
Answer: By "220 breakers", I'm going to assume you mean double pole breakers.  It's also difficult to speculate without actually seeing the panel, or being on site. But here are some thoughts.
Just because a double pole breaker is used, doesn't necessarily mean it's feeding a 240 volt circuit.  In some areas, it's common to use double pole breaker to feed multiwire branch circuits. Which means the double pole breakers could be feeding two 120 volt circuits, instead of a single 240 volt circuit. This is likely the case if you see a bunch of 15, and/or 20 ampere double pole breakers.
It could also be that electricity, is the common fuel source in your area. For example you might have electric dryer, electric range, electric heat, electric hot water, electric A/C, water treatment equipment, secondary panel(s), etc.  Having all electric appliances, can make the double pole breaker total jump quite a bit.
Comment: I can confirm the second paragraph. Many of my lighting circuits use double pole breakers. (Canada).
Comment: In all areas subject to the NEC, 2-pole CBs *must* be used on MWBCs. - 210.4(B) Each multiwire branch circuit shall be provided with a means that will simultaneously disconnect all ungrounded conductors at the point where the branch circuit originates.  [powerdesigninc.us](http://www.powerdesigninc.us/best-practices/2011-NEC-Code-210.4B.doc)
Comment: @Mazura That requirement is met with handle ties as well, so a double pole breaker is not *required* for MWBCs.
Comment: Either or. It's the, "it's common" part I don't like. As of the *NEC two thousand-something*, MWBCs are to "be provided with a means that will simultaneously disconnect all ungrounded conductors". [IME, it's not common](http://diy.stackexchange.com/questions/47658/testing-and-proper-breakers-for-a-multi-wire-branch-circit), but it is now however required by code. 2-pole CBs (or their equivalent!) *must* now be used.
Comment: @Mazura Maybe I've had one too many, but I'm not following your point.  To meet the requirements of the code you pointed out, you can use a double pole breaker, **OR** a handle tie to connect two single pole breakers. However, it's more common to use double pole breakers for MWBCs (at least in areas I've lived), than to use handle tied single pole breakers.
Comment: That last sentence of your comment is somewhat how I expect it to appear in the answer; that's the missing information. And ideally including, "To comply with today's code." Currently, it reads as if *you may find DP breakers used for MWBCs, 'cause that's like a good idea*. - No. It (either or) IS required. ~ "In some areas, it's common to find, and it is now required by the NEC, that DP or handle-tied CBs are used to feed MWBCs." or "In some areas it's required by code that" ~ OP says they only have two 220 outlets; then they've got a box full of MWBCs (assuming no shenanigans).
Comment: @Mazura I guess what I was trying to say is "*in some areas, MWBCs are common*".
Answer: Things that take 220 (actually 240, for the most part in the US system) and don't always have outlets - electric water heaters, electric stove/range/oven, electric resistance heat (typically but not always electric baseboard), air conditioner, heat pump and feeds to subpanels.
And, of course, MWBCs (Multi-Wire Branch Circuits) which have 120V outlets.
A multi-wire branch circuit (MWBC) is commonly used to provide the code-required two 20 amp circuits to a kitchen countertop area, though they can be used in other places. Typically wires are red, white, and black, plus a bare ground wire. The circuit (if an MWBC) will be fed from two side-by side breakers - they should be tied together or a dual-pole breaker under current code, but some older installs will have non-tied breakers.
There is 120V between red and white, 120V between black and white, and 240V between red and black. If both red and black are connected to an outlet on the hot (brass) side, the tab between the halves of a duplex outlet must be broken - we get the occasional "I replaced an outlet and the breaker (sometimes evene the main breaker) tripped as soon as I turned it back on" stories that are frequently from not removing that tab on a MWBC.
To the extent that there are loads on both "sides" of the circuit, current in the neutral wire is reduced to only the difference between the loads - so if one side has loads operating that are 7.5A, and the other has loads operating that are 9.5A, the one hot carries 7.5A, the other hot carries 9.5A and the neutral only carries the difference - 2A.
Comment: @Mazura http://diy.stackexchange.com/a/74739/18078
Comment: This answer could benefit from an explanation as to why MWBCs are on DP CBs and what they are, which I have at length, tried to convince @Tester101 to also include.
Answer: Electric baseboard heaters are a common reason for "lots" of double breakers.


Why is the ratio of two extensive quantities always intensive?

Question: Is this something that we observe that always happens or is there some fundamental reason for two extensive quantities to give an intensive when divided?
Answer: It is mainly a mathematical reason. Extensive quantities grow with system size. If two quantities scale in the same way with a variable (in this case system size), it cancels out in the division.
Mini-example: $A$ and $B$ are extensive physical quantities both dependent on $n$. Their ratio is called $C = A / B$. If you scale the system up, $A$ and $B$ grow by a factor of $n$. What happens to $C$?
$\frac{A \cdot n}{B \cdot n} = \frac{A}{B}$
$C$ stays the same, irrespective of $n$. Hence, $C$ is intensive. The most common physical example is mass and volume, which scale with system size and still exhibit the same ratio, the density.
EDIT including the comment of probably_someone: The argumentation is particularly true since by definition an extensive quantity grows linearly with system size. This justifies the proportionality that I presented in the mini-example.
Comment: In particular, this is true because "extensive" is specifically defined as growing _linearly_ with system size (see e.g. https://en.wikipedia.org/wiki/Intensive_and_extensive_properties), which raises the question: what do we call a property that grows _nonlinearly_ with system size (for example, as the square of the volume)?
Comment: @AaronStevens Whatever the factor is is already included in $A$ and $B$ in this answer. And in particular, if the quantities have different units then not only are the slopes different, they have different *units* so they are clearly very different, but all that is automatically accounted for in the division. Having the same unit but different magnitude is no different.
Comment: Yeah, I did not point this out explicitly. I added a few sentences to include the linearity.
Comment: Technically couldn't the linear relations have different "slopes", so that the part dependant on the size still cancels, but there will be some extra constant factor multiplying your ratio there?
Comment: @AaronStevens Well mathematically, it is definitely possible. I can't think of a suitable example right now though. But as you pointed out yourself, the ratio will still remain intensive.
Comment: @probably_someone you just define it so that it scales linearly with that measure (e.g. it scales linearly with volume, we ignore non-linear scaling with height/width/radius etc)
Comment: @JiK Yes I suppose that is true. Thanks for that


How to correctly install OpenOPC?

Question: Trying to connect Python to an OPC simulated server using OpenOPC. I am able to connect to the server, but when I try to read an item I get Process finished with exit code -1073741819 (0xC0000005). Could this be a problem with the installation of the OpenOPC package?
I am running:
- Windows 10 Pro 64 bits
- Python 3.7 64 bits
- PyCharm
- Graybox OPC DA Auto Wrapper x64
- Pyro 4
- Pywin32
- Matrikon OPC
I have tried running PyCharm as administrator to fix any permission issues, but I still get the same error.
>>> import OpenOPC
>>> opc = OpenOPC.client()
>>> opc.servers()
['AspenTech.OTS_OPCServer.30', 'Kepware.KEPServerEX.V6', 'Matrikon.OPC.Simulation.1']
>>> opc.connect('Matrikon.OPC.Simulation')
>>> opc.read('Random.Real8')
Process finished with exit code -1073741819 (0xC0000005)

Answer: Since OPC uses COM to talk to the Matrikon server, it could be that the 64-bit version of Python is encountering an error.  I have had some similar issues when attempting to do ctypes when someone tries to use a 64-bit version of python to talk to a 32-bit interface.  If I were you I would try with 32-bit Python and see if that resolves the issue.
Comment: Thank you for the answer. I managed to make it work with Python 2.7, I think there might be compatitivity issues with the 3.7 version.

How to correctly install OpenOPC?


STL vector vs list: Most efficient for graph adjacency lists?

Question: Lists consume most of their time in allocating memory when pushing_back. On the other hand, vectors have to copy their elements when a resize is needed. Which container is, therefore,  the most efficient for storing an adjacency list?
Comment: @quasiverse: the requirements on `vector` essentially require a copy as it grows.  `vector`s are required to store their elements contiguously.  As you add elements, you will eventually use up the allocated space, and on the next addition you're going to get a new memory allocation followed by a copy of the current elements to the new space, followed by a deallocation of the old space.
Answer: I don't think this can be answered with absolute certainty. Nonetheless, I'd estimate that there's at least a 90% chance that a vector will do better. An adjacency list actually tends to favor a vector more than many applications, because the order of elements in the adjacency list doesn't normally matter. This means when you add elements, it's normally to the end of the container, and when you delete an element, you can swap it to the end of the container first, so you only ever add or delete at the end.
Yes, a vector has to copy or move elements when it expands, but in reality this is almost never a substantial concern. In particular, the exponential expansion rate of a vector means that the average number of times elements get copied/moved tends toward a constant -- and in a typical implementation, that constant is about 3.
If you're in a situation where the copying honestly is a real problem (e.g., copying elements is extremely expensive), my next choice after vector still wouldn't be list. Instead, I'd probably consider using std::deque instead1. It's basically a vector of pointers to blocks of objects. It rarely has to copy anything to do an expansion, and on the rare occasion that it does, all it has to copy is the pointers, not the objects. Unless you need the other unique capabilities of a deque (insert/delete in constant time at either end), a vector is usually a better choice, but even so a deque is almost always a better choice than a list (i.e., vector is generally the first choice, deque a fairly close second, and list quite a distant last).

1. One minor aside though: at least in the past, Microsoft's implementation of `std::deque` had what I'd consider sort of a defect. If the size of an element in the `deque` is greater than 16, it ends up storing pointers to "blocks" of only a single element apiece, which tends to negate much of the advantage of using `deque` in the first place. This generally won't have much effect on its use for an adjacency list though.
Answer: The answer depends on use-case.
P.S. @quasiverse - vectors call realloc when the memory you "::reserve", implicitly or explicitly, runs out
If you have a constantly changing adjacency list (inserts and deletes), a list would be best.
If you have a more or less static adjacency list, and most of the time you are doing traversals/lookups, then a vector would give you the best performance.
Answer: STL containers are not rigidly defined, so implementations vary.  If you're careful you can write your code so that it doesn't care whether it's a vector or a list that's being used, and you can just try them to see which is faster.  Given the complexity of cache effects, etc., it's nearly impossible to predict the relative speeds with any accuracy.
Answer: You can add third option to this comparison: list with specialized allocator.
Using allocators for small objects of fixed size may greatly increase speed of allocation/deallocation...
Answer: This tutorial site recommends using an array of lists or I guess you can use a vector of list elements instead:  array of lists adj list


Scopes and probes

Question: I have a descent set of probes that are rated at 100MHz, overkill for my current scope, only rated at 15MHz, but I am looking at a couple of different options for used scopes right now, some rated as high as 400 MHz.  Unfortunately, most of these don't come with probes, and if they do there is only 1 (For a 4 channel scope).  As long as I am looking at a signal that has fewer than 100MHz, would it be an issue to use the lower rated probes with a scope that can easily support more than that?
When you exceed the rating of your probe what happens?  Do you just loose definition on your signal?
Comment: Remember to check if your probe can match the scope's input capacitance. Usually in the order of 20pF, and usually printed on the scope's front panel (and in the manual).
Answer: It is safe to use a probe with less bandwidth than your oscilloscope. The probe acts like a lowpass filter so if you do use it to display a signal with greater bandwidth than the probe, the signal display will be degraded; e.g. a square wave will begin to look like more like a sine wave depending on the difference between the signal frequency and the probe bandwidth.  Also, a low bandwidth probe may have more capacitance than a high bandwidth scope is designed for.  That will make it difficult to compensate the probe and will also degrade the display. Unfortunately, probes rated to work with oscilloscopes having bandwidths on the order of 400 MHz can be rather expensive.  However,it may pay to get one probe that can make full use of your oscilloscope's bandwidth and settle for less on the other probes.  That will depend on the types of signals that you will be observing.
Comment: I knew they were pricey, hence wanting to verify the lower bandwidth would work before purchasing anything.  Thanks for the answer and explanations on what to expect!

Scopes and probes


IronPython and ASP.NET

Question: Has anyone built a website with IronPython and ASP.NET.  What were your experiences and is the combination ready for prime-time?
Answer: The current version of ASP.NET integration for IronPython is not very up-to-date and is more of a "proof-of-concept." I don't think I'd build a production website based on it.
Edit:: I have a very high level of expectation for how things like this should work, and might setting the bar a little high.  Maybe you should take what's in "ASP.NET Futures", write a test application for it and see how it works for you.  If you're successful, I'd like to hear about it.  Otherwise, I think there should be a newer CTP of this in the next six months.
(I'm a developer on IronPython and IronRuby.)
Edit 2: Since I originally posted this, a newer version has been released.
Answer: Check out the Dynamic Languages in ASP.NET page on Codeplex. This has the newest IronPython bits. It doesn't give you any Visual Studio integration, other than the sample website project, but that's coming.
Answer: Keep a look out for ASP.NET MVC
The IronRuby guys have got some internal builds of MVC to work with IronRuby, and IronPython 2 and IronRuby have a lot of code in common with the DLR.
I'm not sure if they'll support IronPython/IronRuby when MVC is released, but it's definitely worth keeping your eye on anyway - The old ASP.NET forms-based development model is old, busted, and the sooner it goes away the better.

IronPython and ASP.NET


Can I cash my son's cheques?

Question: My son got a cheque from the Canadian government, but he lost his ID. Instead of taking the cheque to Money Mart which charges a lot of money when they cash cheques, he signed it over to me, I signed it, and I gave him his money. Could I get into trouble for this? If the bank thinks this is wrong, can they put a hold on previous cheques I cashed for him?
Answer: I am not Canadian, but I am posting this as an answer rather than a comment so it can be downvoted as necessary.
Strictly speaking, you aren't cashing your son's cheques. You are cashing the cheques that he has signed over to you: they are your cheques at that point. I think the only wrinkle would be if your son wasn't allowed to sign the check over to a third party in the first place, though I can't imagine why that would be the case.
Comment: In the US, IRS refund checks cannot be cashed over the counter or endorsed to someone else. Perhaps refund cheques from Canada Revenue have similar restrictions.

Can I cash my son's cheques?


How do other magnets affect pickups?

Question: What would happen if you take a magnet to a pickups sound through an amp? Would it kill the pickup or have any affect at all?
Answer: A simplified picture of how an electric pickup works is that: the magnet in the pickup induces the string (steel/nickel alloy) to be a magnet itself.  When you pluck the, string, the magnetized string moves relative to the coils in the pickup.  Moving a magnet near a circuit causes a voltage across the circuit (or equivalently a current for a closed circuit).  This voltage is then amplified by the amplifier.  The complications involve the fact that the magnitization of the string is higher when the the string is closer to the pickup, and less when further away, so the idea of the string just "being a magnet that moves around" doesn't capture the whole picture.  The key point is that moving the string around changes the magnetic field that the coils experience, and thus produce a voltage.
Moving any kind of magnet near the coils will induce a voltage across them.
For a hand held magnet, it would probably be hard to move the magnet fast enough to produce a sound (you'd have to shake it back and forth 10's of times per second), but a strong enough magnet moving fast enough might produce enough voltage to overload an amplifier if it is connected.
Holding the magnet near the pickup while moving string will either enhance (if the magnet is aligned such that it is attracted to the pickup) or degrade the gain in the pickup since the external magnet's field will add to the pickup's field either "in phase" or "out of phase".  Horse-shoe style pickups have magnetic elements both above and below the strings to affect the "shape" of the magnetic field near the strings.
Comment: It is hard to _move around_ a handheld magnet fast enough to be audible. But if you just hold it close to the pickup and tap slightly on it, you will hear a thud, similar to when you hit the strings with your flat hand.
Comment: For anyone appreciating nitty gritty physics details, current and voltage actually aren't equivalent, and a current creates a magnetic field, while a voltage with no current does not. it might be interesting to see if a small magnet attached to the chuck of a portable drill could be made to induce an audible frequency in a guitar pickup.
Comment: I don't want to add another answer because this already answers the question well enough, but you might want to add some information about the e-bow: http://www.ebow.com/home.php which does exactly that. It's an electromagnet which is designed to excite your guitar strings and can be used to create some lush sounds
Comment: @leftaroundabout if you've actually done this, I'd like to hear about the results of what you've done; in particular I'm not sure if readily available magnets are in any way "dangerous" to the amp (or pickup magnets themselves).
Comment: @ToddWilcox reminds me of this https://www.youtube.com/watch?v=B6yLPoMWunc -- note the 0:47 mark where he holds the drill body against the strings -- the electric motor inside the drill involves a rapidly spinning magnet, and I don't hear that the pickups are catching it.
Answer: I've added different types of magnets to both single coil and Humbucker pickups on several different occasions on Strats, Teles, and few different Les Pauls. It has always added a more beefy, fuller sound with brighter, clearer tones like the guitar was actually twice as loud as before with a splitter on the Humbuckers. It made a smooth and fat sound with a treble bleed; it made the treble crystal clean and clear. I have good to awesome results doing this and I didn't go by all the theories and text book indication. I went by the real life results — nothing technical involved at all. I just did it, so live a little. Don't be afraid to do your own thing to discover your own  custom original sound innovation.
Answer: One of the methods a person may use to magnetically charge a pickup pole when winding your own pickups is to stroke the pole with a strong magnet and the pole becomes magnetized itself by this action. With that thought in mind, I would advise caution about playing with a valued pickup and an external magnet, because you can also reverse the polarity and or weaken the poles magnetic field with out meaning to. I often encourage experimentation as a learning tool but I'm also interested in not causing harm to an instrument. Please take care when you fool with your pickups They are quite fragile.

How do other magnets affect pickups?