Is it OK to have a Java Comparator where order can change dynamically?

Question: I have a set of time stamped values I'd like to place in a sorted set.
public class TimedValue {
    public Date time;
    public double value;

    public TimedValue(Date time, double value) {
        this.time = time;
        this.value = value;
    }
}

The business logic for sorting this set says that values must be ordered in descending value order, unless it's more than 7 days older than the newest value.
So as a test, I came up with the following code...
DateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
TreeSet<TimedValue> mySet = new TreeSet<TimedValue>(new DateAwareComparator());
mySet.add(new TimedValue(dateFormatter.parse("01/01/2009"), 4.0 )); // too old
mySet.add(new TimedValue(dateFormatter.parse("01/03/2009"), 3.0)); // Most relevant
mySet.add(new TimedValue(dateFormatter.parse("01/09/2009"), 2.0));

As you can see, initially the first value is more relevant than the second, but once the final value is added to the set, the first value has expired and should be the least relevant.
My initial tests say that this should work... that the TreeSet will dynamically reorder the entire list as more values are added.
But even though I see it, I'm not sure I believe it.
Will a sorted collection reorder the entire set as each element is added?  Are there any gotchas to using a sorted collection in this manner (i.e performance)?  Would it be better to manually sort the list after all values have been added (I'm guessing it would be)?

Follow-up:
As many (and even I to a certain extent) suspected, the sorted collection does not support this manner of "dynamic reordering".  I believe my initial test was "working" quite by accident.  As I added more elements to the set, the "order" broke down quite rapidly.  Thanks for all the great responses, I refactored my code to use approaches suggested by many of you.
Answer: I don't see how your comparator can even detect the change, unless it remembers the newest value it's currently seen - and that sounds like an approach which is bound to end in tears.
I suggest you do something along the following lines:

Collect your data in an unordered set (or list)
Find the newest value
Create a comparator based on that value, such that all comparisons using that comparator will be fixed (i.e. it will never return a different result based on the same input values; the comparator itself is immutable although it depends on the value originally provided in the constructor)
Create a sorted collection using that comparator (in whatever way seems best depending on what you then want to do with it)
Answer: I would advise against this for a few reasons:

Since it's basically a red-black tree behind the scenes (which doesn't necessarily have to be rebuilt from scratch on every insertion), you might easily end up with values in the wrong part of the tree (invalidating most of the TreeSet API).
The behavior is not defined in the spec, and thus may change later even if it's working now.
In the future, when anything goes strangely wrong in anything remotely touching this code, you'll spend time suspecting that this is the cause.

I would recommend either recreating/resorting the TreeSet before searching it or (my preference) iterating through the set before the search and removing any of the objects that are too old. You could even, if you wanted to trade some memory for speed, keep a second list ordered by date and backed by the same objects so that you all you would have to do to filter your TreeSet is remove objects from the TreeSet based on the time-sorted list.
Comment: +1 for pointing out that it's not specified and could thus change at any time in the future.
Answer: I don't believe the JDK libraries or even 3rd party libraries are written to handle a comparator whose results are not consistent.  I wouldn't depend on this working.  I would worry more if your Comparator can return not-equal for two values when called one time and can return equal for the same two values if called later.
Read carefully the contract of Comparator.compare().  Does your Comparator satisfy those constraints?
To elaborate, if your Comparator returns that two values are not equals when you call it once, but then later returns that the two values are equal because a later value was added to the set and has changed the output of the Comparator, the definition of "Set" (no duplicates) becomes undone.
Jon Skeet's advice in his answer is excellent advice and will avoid the need to worry about these sorts of problems.  Truly, if your Comparator does not return values consistent with equals() then you can have big problems.  Whether or not a sorted set will re-sort each time you add something, I wouldn't depend on, but the worst thing that would occur from order changing is your set would not remain sorted.
Comment: As far as I can see, the contract doesn't specify that the ordering imposed by the comparator has to stay constant over time. But I can't imagine that you could get away with it in the general case.
Comment: I am most concerned with whether or not the Comparator is consistent with equals().  If not, chaos may occur.
Answer: I am 99% certain this will not work. If a value in the Set suddenly changes its comparison behaviour, it is possible (quite likely, actually) that it will not be found anymore; i.e. set.contains(value) will return false, because the search algorithm will at one point do a comparison and continue in the wrong subtree because that comparison now returns a different result than it did when the value was inserted.
Answer: No, this won't work.
If you are using comparable keys in a collection, the results of the comparison between two keys must remain the same over time.
When storing keys in a binary tree, each fork in the path is chosen as the result of the comparison operation. If a later comparison returns a different result, a different fork will be taken, and the previously stored key will not be found.
Answer: I think the non-changing nature of a Comparator is supposed to be on a per-sort basis, so as long as you are consistent for the duration of a given sorting operation, you are ok (so long as none of the items cross the 7 day boundary mid-sort).
However, you might want to make it more obvious that you are asking specifically about a TreeSet, which I imagine re-uses information from previous sorts to save time when you add a new item so this is a bit of a special case.  The TreeSet javadocs specifically defer to the Comparator semantics, so you are probably not officially supported, but you'd have to read the code to get a good idea of whether or not you are safe.
I think you'd be better off doing a complete sort when you need the data sorted, using a single time as "now" so that you don't risk jumping that boundary if your sort takes long enough to make it likely.
Answer: It's possible that a record will change from <7 days to >7 days mid-sort, so what you're doing violates the rules for a comparator. Of course this doesn't mean it won't work: lots of things that are documented as "unpredictable" in fact work if you know exactly what is happening internally.
I think the textbook answer is: This is not reliable with the built-in sorts. You would have to write your own sort function.
At the very least, I would say that you can't rely on a TreeSet or any "sorted structure" magically resorting itself when dates roll over the boundary. At best this might work if you re-sort just before displaying, and don't rely on anything remaining correct between updates.
At worst, inconsistent comparisons might break the sorts badly. You have no assurance that this won't put you into an infinite loop or some other deadly black hole.
So I'd say: Read the source code from Sun for whatever classes or functions you plan to use, and see if you can figure out what will happen. Testing is good, but there are potentially tricky cases that are difficult to test. THe most obvious is: What if while it's in the process of sorting, a record rolls over the date boundary? That is, it might look at a record once and say it's <7 but the next time it sees it it's >7. That could be bad, bad news.
One obvious trick that occurs to me: Convert the date to an age at the time you add the record to the structure, rather than dynamically. That way it can't change within the sort. If the structure is going to live for more than a few minutes, recalculate the ages at some appropriate time and then re-sort. I doubt someone will say your program is incorrect because you said a record was less than 7 days old when really it's 7 days, 0 hours, 0 minutes, and 2 seconds old. Even if someone noticed, how accurate is their watch?
Answer: As already noted, the Comparator cannot do this for you, because the transitivity is violated. Basically, in order to be able to sort the items, you must be able to compare each two of them (independent of the rest), which obviously you cannot do. So your scenario basically either would not work or would produce not consistent result.
Maybe something simpler would be good enough for you:

apply simple Comparator that uses the Value as you need
and simply remove from your list/collection all elements that are 7 days older then the newest. Basically whenever a new item is added, you check if it is the newest, and if it is, remove those that are 7 days older then this.

This would not work if you also remove the items from the list, in which case you would need to keep all those you removed in a separate list (which by the way you would sort by date) and add those back to the original list in case the MAX(date) is smaller after removal.


Android links not working in a webview

Question: Basically I'm parsing the HTML of a web page and then loading it into a webview via a string using "loadData". My problem is this stops my links working, the webview doesn't know the current URL of the page so when a link is clicked rather than loading http://myurl.com/page.html it tries to load http://page.html which clearly doesn't load.
Does anyone know how to solve this problem without editing the HTML pages?
Answer: http://developer.android.com/reference/android/webkit/WebView.html#loadDataWithBaseURL(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

Android links not working in a webview


Do major chess publishers use custom software for typesetting chess books?

Question: As I try to understand how one would publish a large chess book, it feels that chess gives some pretty custom requirements for an editor or publisher. I am pretty sure that chess authors use Chessbase or similar software for writing their books and then pass them off to editors who proofread and do all the final layout and typesetting for printed version. Since Chessbase does not support proper document management (export to RTF is as far as it goes), and layout software like InDesign don't support adding chess diagrams, do software publishers like Gambit, Everyman chess, Quality Chess, etc have their own chess aware custom publishing tools? Or do editors just use regular publishing software and then insert diagrams by hand to optimize for page space as they see fit, with plenty of room for manual errors (i.e. inserting diagrams that don't match the moves)?
Comment: Dunno the general case (so this is a comment), but German chess problem journal "Die Schwalbe" at least have their own fonts (not surprising given the need for fairy chess symbols).
Answer: This is less a question about chess, than a publishing question.  The answer is:

No.  The publishing industry largely uses publishing software (open source, and proprietary) to publish books, including chess books.  You've named one - InDesign.

Software such as Adobe's InDesign or Open Source software such as SILE or LaTex can lay out a book given the correct font.  Fonts can be used with Typesetting software to represent positions and pieces.
For example a common book font is Chess Mérida:

This font also includes black backgrounds and pieces on backgrounds so you can make images such as:

The font converts that from the text:
<code>!""""""""#
$tMvWlVmT%
$OoOoOoOo%
$ + + + +%
$+ + + + %
$ + + + +%
$+ + + + %
$pPpPpPpP%
$RnBqKbNr%
/(((((((()
</code>
(Download the font here and cut that text into a Word Document and change the text to the Chess font and see for yourself)
You can find many chess fonts to use with your publishing software here.
Comment: I can't answer for Gambit, but I can ask some of my friends with experience working there.  If you want to typeset books on your own, consider LaTeX with skak package.  Seems to work well, according to https://www.sharelatex.com/learn/Chess_notation
Answer: I also had this question, and as a graphic designer, I was stunned to find no real solution was created for InDesign, and LaTeX was the only viable option to typeset a book or magazine.
So I took it upon myself to write a script to create scalable chess diagrams from FEN notation. I also created a font family for figurine chess notation.  I know it's late for this. But no one else has created it, and I figure someone will find my solution helpful.
Here is a video to show how easy it is to use.

For more information and to download the free script and font, see my website.
Answer: All publishers have their own software and standards for publishing.
Are you self publishing and printing your own book?  If not then you must ask whoever will print or publish the book what their requirements are.
When I was a small publisher looking at this I just used a chess font and arranged the diagrams myself.  But that was several decades ago.  Now there is fancier software to help book layout including chess specific ones.
Answer: I'm not a major publisher, but I have re-published some old books on chess problems electronically. I ended up using InDesign, but before that I used FrameMaker, Tex/LaTeX, ... and I could have done a decentish job with Word or WordPerfect once I had figured out what could and could not be done well.

and layout software like InDesign don't support adding chess diagrams,
do software publishers like Gambit, Everyman chess, Quality Chess, etc
have their own chess aware custom publishing tools?

It is almost irrelevant what InDesign and other tools support.  Hot type setters did not have anything but their hands and their type, and they still managed to do some very good books.  InDesign did (and probably still does)
have so much fundamental support for type setting -- as does TeX (and so LaTeX) -- that you can make do without intrinsic hand-holding. You will need some external tools, such as character set converters, and diagram editors.
In my case, I had a fixed page format, and a design page size and font to work with.  No scaling, no resizing, no user-specified fonts, font sizes or page sizes (i.e. no e-books like Kindle books). Diagrams were based on Partae Hastings or Linares diagram with some custom edits to avoid the original and excessively wide border type, allowing diagram edges to snug up against column edges with no white space. Both families (if I recall) had special diagram sets, including rotated pieces.
Then, each diagram (in text form using the Partae character mapping) was
imported and assigned the font. Paragraph formatting was adjusted to set lines solid, and not allow any adjustments or hyphenation.  The first line typically needed to be adjusted for vertical spacing, but first line was always diagram border ("cuuuuuuuuC"), and so very easy to search-and-replace paragraph format, and the last line could usually need less space after, too.
The result works well with module-based book design, as it is rather static.
(I've not done anything in this line for perhaps 15 years, but you can find whatever I did at http://www.anders.thulin.name/old/oldstuff/ )
A similar approach would work for chess moves, but you would have to decide how you wanted the moves displayed before hand (but that is typically a house style, and doesn't change much).  Changing your mind half-way through a book would not be a trivial thing, though. (I mean, entering a game, and then deciding short algrebraic in two columns, changing to full algebraic, then trying figurine in-line, and ending up with English descriptive would not work without considerable support: in InDesign it would probably be technically possible to write a plugin for it, ... but very few would need it, as that kind of indecisiveness belongs elsewhere than in a publishing shop. IMNSHO.)
For a very well done chess book by a major publisher look at C. H. O'd. Alexander's Fischer v. Spassky Reykjavik 1972 (Penguin Books, 1972), designed by Derek Birdsall.
Comment: The author would almost certainly be expected to produce final copy, both for text, game scores and diagrams.  In such cases, the copy would contain the full PGN game and a full diagram, suitably marked up, and there would be some kind of prior agreement exactly how those would transfer to a final page, probably with a print-out given to the author so that he could see what the end-result would be. (There are always special cases, though, say, of authors insisting on hand-writing a manuscript, or inking unreadable diagrams.)
Comment: Thanks for explaining your experience, I am pretty unfamiliar with the world of Indesign and fonts, but I wonder how does the publisher iterate between the editor and author where the author submits pgn's and text outside of games, while the editor typesets diagrams in Indesign. Author adds a diagram here and there in pgn for 3rd draft, and Editor does ... exactly what?
Comment: Would they have to retypeset the book from scratch so that no differences have been missed? or (more likely) edits are disallowed, and every typo fix needs to be communicated by email and manually propagated into publishing format. And a serious publisher would have to do this for dozens of books per year.
Comment: For a general description, see Marshall Lee's book Bookmaking (I think the 3rd ed. is the latest.)


How do I connect my Xbox 360 controller to my 2.4Ghz wireless gaming receiver if it doesn't have a connect button?

Question: How do I connect my Xbox 360 controller to my 2.4Ghz wireless gaming receiver if it doesn't have a connect button?
Comment: We definitely need more details.  Can you link to Amazon or some other retailer/manufacturer of the receiver? That may help.  How are you planning on using this as well? Like Controller → receiver → PC?
Comment: Hi Jeremy, what does this have to do with Steam? Can you tell us what model of wireless receiver you have?
Comment: It only says 2.4g wireless gaming receiver on it
Answer: It does not matter whatever the "receiver" questioner uses, unless it's official USB dongle which is now EoL.
Xbox 360 controller does not have Bluetooth connectivity or any of the normal connectivity, instead it uses proprietary RF(radio frequency) interface. Bluetooth connectivity is only available for Xbox One controller and newer.
Just in case, some sources:
Wikipedia(states that it uses proprietary 2.4 GHz protocol)
Superuser question
And just in case if questioner is using official USB dongle:
Microsoft webpage


How to create a file upload field in a form in Pardot?

Question: I've created some forms in Pardot and I need to add a file upload field to one of them but I don't know how. I couldn't find such field type in custom fields as well
I attached an image to explain what I want to create.can anybody help?
Answer: Using pardot forms this isn't currently possible. I'd suggest creating your own form or use a 3rd party form and post the data to pardot using a form handler
You'd need to store the file upload within a separate location as pardot wouldn't be able to host the file from a form submission


Set "User Defined Runtime Attributes" in code

Question: This may be a silly question but I couldn't find an answer anywhere.  If I want to create a UIButton in code and need to set a runtime attribute how would I do so without the interface builder and strictly in code?
Comment: What kind of attribute? Call a method on the button instance...
Answer: Actually figured this out, like I said silly question.
[UIButton *loginbtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[loginbtn setValue:@"blah" forKey:@"myAttr"];

Answer: When you set a runtime attribute in Interface Builder, what you're actually doing is instructing the Nib loading machinery to call the corresponding setter method on that object during Nib loading. So, if you have a runtime attribute called for example "name" with a string value of "Bob", all that means is that at some point at runtime during Nib loading, the instance's -setName: method will be called with @"Bob" as the argument.
So, to do the same thing at runtime, you just set the property directly, perhaps in your view controller's -viewDidLoad method, or another appropriate place:
self.button.name = @"Bob";

Comment: or at the view's init or awakeFromNib
Answer: Wanted to provide an updated answer which leverages Swift property wrappers to cleanly attribute UI elements which should be ignored.
Swift 5.1+ Property Wrapper
@propertyWrapper
public struct HeapIgnore<T> {
    public var wrappedValue: T {
        didSet {
            (wrappedValue as? NSObject)?.setValue(true, forKey: "heapIgnore")
        }
    }

    public init(wrappedValue: T) {
        self.wrappedValue = wrappedValue
    }
}

Example Usage
... // Inside ViewController
@HeapIgnore
@IBOutlet private var passwordTextField: UITextField!

I've implemented this solution and confirmed in both the Live View and Events Visualizer that Heap ignores events generated by UI elements attributed with the property wrapper.
Answer: You need to reference somehow the UIButton in the code (usually by creating an IBOutlet) and then you can access its properties as you would do when you create a button programmatically.
If you want to create the button programmatically for instance:
    UIButton *button = [[UIButton alloc] initWithFrame:frame];
    [button setTitle:@"Title" forState:UIControlStateNormal];


Restoring WoW6432Node

Question: I feel real stupid about this one.
Before I go any further I would like to state that I have a registry backup I created two hours prior to this and I should have system restore checkpoints all over the place.
Recently I had somehow corrupted SolidWorks and I was manually uninstalling all it's components, including registry components. Somehow as I was selecting the SolidWorks registry folder in WoW6432Node I ended up selecting the parent directory and sort of deleting (almost) all it's contents...
After this I could not run the registry backup I made (with CCleaner so I'm not 100% sure how complete it was), mainly due to the fact that the file hierarchy of windows is now completely screwed. I also couldn't run system restore, and so I decided to try running using a System Repair Disk I prepared on my laptop.
Sadly this process required me shutting off my, and my luck has gone ever since. First I receive a message saying "Cannot find Recovery Partition". Next, when it tried to run system repair it couldn't find C:.
One (possibly useful) thing it did was add a previous Windows install I had kept from my hdd days to the boot list.
Later when I reached a menu that let me select system restore when I tried navigating to C: all I could see was a few temporary files.
For now I've booted into the old hdd OS. I can explore the my primary boot drive but the question is how can I repair the OS? Is there anyway I can restore that registry while I'm on a different OS. Can I initiate a system restore for that partition from this OS; I certainly haven't had much luck when I've tried to run repairs from my repair disk...
I'd really like to not reinstall the main OS, and I guess I could always migrate my hdd to the ssd, but I'd like to exhaust all the possibilities first.
EDIT: As an update, so far I have found my recent System Restores for the primary drive as options options on my hdd OS System REstore.
Comment: I still don't have a full grasp on registries but one of my ideas was using Recuva from Piriform to try and restore any files that were deleted thanks to my edits, but I get the feeling that the SysWoW64 folder and registry entries are loosely related and this wouldnt help at all.
Answer: So after speaking with several people on SE Chat, the solution was relatively simple:
I booted from my other OS and manually restored my registry located in C:\Windows\System32\config and the backup folder in that directory. The CCleaner backup I had is only minimal and would restore things I had already deleted using the service.

Restoring WoW6432Node


Distribution of conditional posterior for Gibbs sampling

Question: The following is a description of how the authors (Yongning Wang & Ruey S. Tsay) of this (2019) paper Clustering Multiple Time Series with Structural Breaks want to perform Gibbs sampling to obtain cluster memberships. i.e. let's say c can become 1,2 or 3, meaning an individual n can belong to cluster 1,2 or 3. If I perform Gibbs sampling I get stuck, as the posterior distribution they describe is non-standard. How do they get to the probability statement? It seems like the big term before $\eta_{sc}$ is simply a scalar and does not influence individual draws.
Comment: @user773674 the categorical distribution with the given probability. To be more precise, calculate the expressions for c = 1,2,3 and store those in a vector. Then, divide that vector by its sum. Then, sample (1,2,3) with probability given by that vector.
Comment: The $n^{th}$ individual is sampled to group $c$ with a probability $p$; $p$ is not the group, but the probability of choosing that group.
Comment: @LucasRoberts (the article is available on Scihub ;)). I just went through the paper to double check, looks like this article is describing a fully Bayesian procedure, with the exception of the total number of clusters K, which is selected via marginal likelihood maximization (aka empirical bayes).
Comment: It seems to me that the probability only depends on $$\eta_{sk}$$. Note that k and c are the same here, the appendix is weird with notation.  As all variables within the product over all k's for all individuals n=1,...,N, doesn't influence the proportions between the probability of i.e. let k in {1,2,3}. Then $$p(c_{n,(s)}=1)$$, $$p(c_{n,(s)}=2)$$, $$p(c_{n,(s)}=3)$$ only depend on the eta term, as the terms with sk subscript in the product remain the same no?
EDIT: all conditioning left out of notation obviously
Comment: Yes, maybe I was not clear. I meant to ask what then the distribution is that I am to sample group c from given these probabilities. Edit : thanks for your response!
Comment: @JohnMadden that sounds like a Monte Carlo EM variant. Alternately you could assign deterministically to the largest probability (using lexicographic order to break ties if necessary), no? NOTE: the paper is paywalled for me so I'm not clear if the Author's do an MC-EM variant or a straight maximization, picking the largest probability.
Comment: @LucasRoberts what you're describing sounds like some kind of EM (but usually cluster assignments are expected, not maximized, in EM algos). I do not view what I/the OP described as an EM algo, but rather as a standard Gibbs sampler.
Comment: I agree with @JohnMadden - this looks like a standard Gibbs sampler to me too.
Comment: @JohnMadden
Would you agree the probabilities given are problematic since we do not obtain a probability for any group c that is not in $C_{s}$ i.e. is not present during regime s. And for the c's that are present in $C_{s}$ probability is only scaled by the big term and depends on $\eta_{sk}$. Which is modelled independently?
Answer: The time-series model in the paper is

multivariate with $N$ time series of duration $T$
regime-switching, meaning that the model parameters are changing at random  times (with indicators $s_t$), with an unknown number $S$ of switches
clustered, meaning that during one regime (time interval) $s$, the components of the time series are driven by one of $K$ models, with all components in the same cluster $k$ following the same model (sharing the same parameter $\theta_{sk}$

When considering a Bayesian modelling of this setting, simulating the parameters and the latent variables (regimes and clusters) can be done by Gibbs sampling. For the cluster allocation, this can be done conditional on the regimes $\mathbf s^T$ and the parameters, since the clustering is independent between regimes. Each component $n$ of the time series vector can then be allocated to one of the $K$ clusters, conditional on the other components, with a probability
$$\mathbb P(c_{n,s}=\kappa)\propto \eta_{s\kappa} \prod_k \int f(\mathbf y_{ns}|\theta_{s\kappa})\pi(\theta s_k|\mathbf y_{-n,s})\,\text d\theta_{sk}\tag{1}$$
that has integrated out the first level parameters, thanks to the conjugacy of the priors (cf. (A-19) in the Appendix A-3). Since the rhs is available in closed form, the simulation of $c_{n,s}$ is straightforward as a discrete distribution on $\{1,2,\ldots,K\}$, as indicated in John Madden's comment.

calculate the expressions for c = 1,2,3 and store those in a vector.
Then, divide that vector by its sum. Then, sample (1,2,3) with
probability given by that vector.

This is one step of a partly integrated Gibbs sampler that is perfectly valid. Note that, due to this integration of the first level group- and cluster-dependent parameters, the components $\mathbf y_{ms}$ are no longer (conditionally) independent, which is why they all appear in the right hand side of (1).
Comment: Would you agree the probabilities given are problematic since we do not obtain a probability for any group c that is not in $C_{s}$ i.e. is not present during regime s. And for the c's that are present in $C_{s}$ probability is only scaled by the big term and depends on $\eta_{sk}$. Which is modelled independently?


How trade engine works?

Question: How cryptocoin trade engine works? Is there any open source project available other than buttercoin. I want to build a simple trade engine in ruby on rails for cryptocoins. what are the essential parts needed other than API?
Answer: You can code a trade engine in language like C++ or any other which ever is suitable for you. What actually happens in the back-end is an script keeps on repeating after particular interval for new trades or deposits that script can be coded in any language which can communicate with the database. Following is the example of a PHP script which checks for new trades and then update the database if any new trade took place:
<code><?
$sell = mysql_query("SELECT * FROM trades WHERE `From`<>`Type` LIMIT 1000000000000");
$num = mysql_num_rows($sell);
echo $num;
for ($i = 0; $i < $num; $i++) {
$id = mysql_result($sell,$i,"Id");
if($id != 0)
{
    $trade = new Trade($id);
    $trade->GetEquivalentTrade();
    $trade->ExecuteTrade();
}
}
?>
</code>
Comment: Why all the downvotes? This answer appears at least somewhat useful to me. Is there something actually wrong?
Comment: @Khan- It seems useful.
Answer: There is Toblibot and Gekko and maybe some others.
I like Gekko quite a bit.
A quick google search will reveal them to you.

How trade engine works?


Other Side of an Einstein Rosen Bridge

Question: We get an ERB when we replace $u^2$ by $r - 2M$ in Schwartzchild Metric, therefore the metric becomes symmetric along the horizon $(r = 2M)$. Why should it mean that crossing the horizon leads you to another universe? Why not just the other side of the same black hole, or even you simply trace your way back home? What part of the ERB metric makes us think that it leads to another universe?
Answer: $r$ is greater than $0$. When it is greater than one, we are outside the horizon of the black hole. When it is between zero and one, we are between the singularity and the horizon.
That is all (in our universe), but represents regions $1$ and $2$ respectively of the ER diagram. Regions $3$ and $4$ are speculative 'out of our universe' places.

Other Side of an Einstein Rosen Bridge


Bathroom above the Garage

Question: Is it advisable to build a bathroom above the garage? What kind of obstacles might we face if there is a bathroom above the garage in terms of piping, insulation, etc.?
Comment: It depends on the climate you live in.
Comment: ...and whether the garage is heated or not, if the climate is cold.
Comment: Where your main waste line exits the house is a consideration too.
Comment: Would you rather have water leaking into your living room or your garage?
Answer: List of issues:

Getting the space conditioned.  This may be really easy or insanely difficult.  Depends on what is on the other walls of bathroom and where your ducts are in your house.
Getting electric.  Should be no big deal.
Getting water.  Might be a bigger deal than electric but probably not a huge thing.
Getting exit plumbing.  Given that the bathroom is on a second level you have a lot more options but you will probably have to open a few walls to get plumbing to your main stack.  Your shower and faucet aren't a big deal.  It is your toilet that would be concern.  You don't want to run a long solid waste line with low slope.
Venting.  Should be easy since you are on second level.

So biggest issues are #1 and #4 for a bathroom above garage.  If you get these easily figured out the rest shouldn't be a huge deal.
Answer: Generally speaking building anything on top of garage isn't be idea in the world, but I'm guessing that you are in need and it's not because you have nothing better to do, it can be done, and if you ask me it is not more complicated  than doing it anywhere else. First and the most important thing: WATER PROOFING and THERMAL INSULATION. You should have two layers of water proofing; one that is protecting the bathroom from "outside" water (humidity etc.) and the other which is protecting everything else from bathroom water. First layer should be placed on top of garage slab, and second one right under ceramic tiles. I have skipped one step, well actually I'm taking it for granted and that is the question whether your slab can support extra weight. After water proofing put some thermal insulation, and cover it with cement screed. Also keep in mind that your walls and ceiling should also be thermally insulated. Then you put some simple roof on top of it cover it with metal sheets or something similar, if possible put some gutters and that's it. When it comes to plumbing (water and sewerage) that could be the biggest problem, put I cannot tell anything about it since I'm not fully familiar with your situation.
Comment: Your answer seems to be to the question "building a bathroom IN the garage", not (as asked, albeit with no useful details yet) ABOVE the garage.
Comment: @Ecnerwal how do you mean? What do you think that I left out? I haven't mentioned details about building the walls but I'm presuming that implies. If you think I should add something feel free to edit the answer or you can suggest me how.
Comment: Waterproofing the garage slab...? Somewhat irrelevant for a bathroom *above* the garage.
Comment: I agree that it might sound irrelevant but if you ask me you cannot be to caucus with waterproofing. It doesn't cost too much money but water can cause soooo much damage, so I always think about the worst case scenario. Like there is no guarantee that garage slab is under slope, and water can collect right next to bathroom walls and go under, I don't think that it should be left out.

Bathroom above the Garage


High volume equity sale w/price lower than bid and ask. What is this?

Question: Can someone explain this sale below. First time I have seen this, and I don't understand what happened here. The stock is trading in the post market at $11.90 with normal volume for that time of day, and this one sale comes across for 38,886,200 shares at $11.72. It didn't affect anything. Is this some sort of ECN balancing or something?
Comment: Are you sure the volume is in thousands?
Comment: My bad. I meant 100s. It should be 38,886,200 shares. One too many zeros.
Answer: The most basic explanation is that there was a buyer for that many shares when there was a seller for that many shares.  When that occurs, price does not change.
A more likely explanation is that it was a cross trade:
A cross trade also occurs legitimately when a broker executes matched buy and a sell orders for the same security across different client accounts and reports them on an exchange. For example, if one client wants to sell and another wants to buy, the broker could match those two orders without sending the orders to the stock exchange to be filled but filling them as a cross trade and then reporting the transactions after the fact but in a timely manner and time-stamped with the time and price of the cross. These types of cross trades must also be executed at a price that corresponds to the prevailing market price at the time.
Comment: That is what I would think normally, except for the trade amount. This trade would have equalled $4.5b. The equity was Norwegian Cruise Lines. The Saudi Sovereign Fund bought 43.5m shares of Carnival and that made headlines. It seems kind of improbable that someone bought these.
Comment: If it showed up on the ticker then the trade was made and someone bought the shares.
Comment: Could be. There was an error above, I had an extra zero. It was $455m.


Maximum weighted matching in Bipartite Graph

Question: I was solving a coding question which boiled down to this problem.
Given a bipartite graph $G=\{V\cup U,E\}$. There is a positive value given for every node in  $U$.
Now we have to find the matching in which the sum of value of every node in $U$ which is also in the matching is maximum.
Consider an example, Let valueArray for $U = [1,2,3]$ . If in a matching nodes 0 and 1 of array are in matching the value of matching will be valueArray[0]+valueArray[1] = 3.
We have to find this maximum possible value of all possible matching given the graph and valueArray.
Matching nedd not be of maximum cardinality.
Comment: It's unclear what you want to maximize. Let $M$ be the maximum cardinality over all matchings of $G$ (recall that a matching is a set of edges). Are you looking to maximize (i) the sum of the values of the matched nodes in $U$ over all possible matchings of $G$, or (ii) the sum of the values of the matched nodes in $U$ over all possible matchings of $G$ of cardinality $M$?
Comment: It is i) There is no cardinality constraint on the matching
Comment: Then you just want a maximum weight bipartite matching. Use the transformation in Pål GD's answer to get the edge-weighted variant. Then add dummy edges of weight $0$ to ensure that a perfect matching always exists.  Finally, use any algorithm for minimum/maximum weight bipartite matching. See again Pål GD's answer.
Comment: Thanks for answer. But I was thinking whether the question has a simpler solution as it was one of the three question asked in exam having 60 mins time to complete the code for all the three.
Answer: You can turn the problem into an edge-weighted variant by setting the weight on edge $vu$ to be $\texttt{valueArray}(u)$ where $w(vu) = \texttt{valueArray}(u)$ is the value of $u \in U$.
Now a maximum weight matching in this graph is a matching which maximizes the sum of the values of the nodes in $U$.  Note that you can flip the sign of all values to obtain a minimization problem, and if you add all missing edges with $w(e) = 0$.  Now you have a minimum-weight perfect matching problem.
Ps, this is called the assignment problem and can be solved using LP, by the Hungarian algorithm (augmenting paths), or the min-cost max flow algorithm.


Force of air lift

Question: Say I want to find out how much wind force I would need to lift a tank 10 meters in the air, given I already know its dimensions. Is there a formula for that?
Answer: The volume of air travelling at speed $u$ hitting a perpendicular, flat surface of area $A$ in a time $t$ is $V=Aut$, and its mass is $V=\rho A ut$.
Force is given by change in momentum with respect to time: $F = \frac{dP}{dt}$, or, assuming $u$ is constant: $F=u\frac{dm}{dt} = Au^2\rho$, assuming that all air molecules inelastically collide with the surface. If the collision is perfectly elastic, you pick up an extra factor of $2$.
Thus, setting $F=m_\text{tank}g$, you get: $\sqrt{\frac{m_\text{tank}g}{2A\rho}}<u<\sqrt{\frac{m_\text{tank}g}{A\rho}}$ .
Comment: I understood up to V = Aut, but after that you lost me. Could you possibly go more in-depth about the variables, as I'm not versed at all in Physics?

Force of air lift


Can SSDT deploy SQL server service broker objects?

Question: Can SQL Server Data Tools (SSDT) deploy sql server broker objects? (So contacts, message types, services, queues and so on.)
Answer: It would appear so. I have not tried these, but the following is the list of items that can be added to an SSDT SQL Server Database Project:

Broker Priority
Contract
Endpoint (ServiceBroker over TCP)
Endpoint (SOAP over HTTP)
Event Notification
Message Type
Queue
Remote Service Binding
Route
Service
Comment: Any reason why DacPac deployment skip route changes? Any advance settings needed for SSDT/Data-Tier project?


linking android application with google app engine datastore

Question: i am looking for a link through a web service between an android application and an application that is deployed on google app engine.the user inputs data in the android application which has to be passed to the jsp and jpa application deployed on the google app engine.Can anyone please help...
Answer: See this article for how to authenticate against App Engine from inside your Android app. From there, how you interface is up to you: You can write a RESTful API, or use any number of HTTP-based RPC protocols to communicate between the Android app and the site. Which you choose depends on your needs, which you haven't detailed.


What are the consequences of deleting a property in Google Search Console?

Question: I plan to delete the Google Search Console property for my website. What are the consequences of doing so?
Answer: If you delete the property from search Console. You will lose all the past search performance data (from which Keyword, you are getting how much impression, your SERP Rankings etc).
Apart from that, you will lose the international targeting (if you have set, that you want to target specific country), after deleting it will universal.
You will lose control over your site's sitemap contribution from your side to Google. You won't able to tell Google, which page you need to index, google will decide.
You will lose control to set Sitelinks for your website, which appears in Google search engine when someone search your brand name.
You won't be able to remove any url of your site from google, if you want.
Overall, you will be breaking the bridge between your site and Google.
Comment: All true.  It also might be worth saying what you won't lose.  Deleting a property won't remove your site from Google's index.  Unless you have tweaked the special setting you outlined, it shouldn't change your SEO at all.
Comment: My question is, if you then re-add the property back, will all the old data show again or will it start from scratch?


what is the best library for converting video to multiple resolutions

Question: as I see there are two popular ffmpeg and avconv, for example what uses youtube or other popular platforms for converting one video to multiple resolutions, subtitles and audio tracks etc...are these libraries okay or is there a better solution?
Comment: Are you trying to build software to help others convert videos or are you converting your own video? If it is the latter, can you be more specific about what criteria you define "okay" and "better"? If it is the former, that is off topic here and better suited to one of the other SE sites.
Answer: You have answered your own question on this one, ffmpeg is the de facto standard for this type of work, there really isn't any reason to use anything else. It's free, fast, works on almost any imaginable platform, and can be easily integrated into almost any workflow because of how many ways it can be called. You can even use it to apply special filters.
If you aren't comfortable using the command line, there are many GUI interfaces available that will give you a nice interface for using ffmpeg. One good example is myffmpeg but there are many others.
If your goal is to always convert using the same settings though, the absolute best way to achieve this is to create a simple ffmpeg batch/shell script (depend on which OS you're using) that you simply run that script and it does its thing - no effort once it's set up the first time.


Why does light show a no interference result?

Question: I was reading the first chapter in the Feynman lectures volume 3 about quantum mechanics and I understand the concept that 'interference' means $P_{12}=P_1+P_2$ as expected, however when the electron gun experiment is done with a light source behind the two holes the graph shows a no interference result, isn't the light supposed to interfere with the electron?
Comment: Doesn't Feynman go on and explain what is going on? Anyway, the light bouncing off the electrons would allow one in principle to tell which slit the electron went through. This is the famous "wavefunction collapse". Now the two paths cannot interfere with each other.
Answer: Interference is with a single type of wave, so sound waves interfere with other sound waves, and light waves interfere with other light waves. Generally sound waves don't interfere with light waves and vice versa. In the formula you wrote it wouldn't make sense to add $P_1$ and $P_2$ if $P_1$ is the pressure of a sound wave and $P_2$ is the strength of the E-field, it would be adding apples and oranges (the units don't even match).
The electron wave is not the same type of wave as a light wave, so you would not expect that the electron wave would interfere with the light wave or vice versa. Now, of course, electrons and light do interact with each other, but that interaction is not a simple interference.


No wiring diagram on motor!

Question: I have no idea where to connect my power leads to this electrical block on my saw motor, its a 220v single phase, the white wires are the capacitor.
Answer:

simulate this circuit – Schematic created using CircuitLab

Disconnect the wire at 5 and confirm with a multimeter that one coil (MAIN) is terminated at 1 and 4.
While 5 is disconnected check for continuity between it and 3.
If wiring is as shown then apply power directly to the MAIN coil on 1 and 4 (or 2 and 5).

The capacitor causes a small phase-shift in the current in the START winding relative to the MAIN winding so that a definite starting torque and direction is produced.
(The wires on 4 and 5 may be swapped. You should be able to figure this out. Either way, apply mains to 1 and 4, etc.)

No wiring diagram on motor!


Calculating key dates for a Forward Starting Interest Rate Swap versus a Spot IRS

Question: How are the Effective Dates and Maturity Dates of a forward starting IRS (eg: EURIBOR3M 5Y5Y) handled when the forward starting term ends on a non-business day? And if that date is adjusted, how does that impact the maturity date of the forward starting IRS?
For example if I trade on 6th Jan 2023, the T+2 spot date becomes Monday because I am trading on a Friday. For a EURIBOR 10Y that would result in a maturity date of 9th Jan 2033.
For the matching 5Y 5Y traded on the same day, the Effective Date falls on a Sunday (9th Jan 2028) which I presume would be adjusted to the Monday (10th Jan 2028)...which would then imply a maturity date of 10th Jan 2033. Which is mismatched vs the 10Y.
If, however, the Effective Date remains unadjusted, the maturity of the 10Y would match the 5Y5Y but the forward term would be less than 5 years.
How does the market get around this issue?
Answer: If you trade a 10Y IRS, the second half of that IRS represents a 5Y5Y from the point of view of a swaps dealer.
If a swaptions dealer trades a 5Y5Y Swaption the 5Y swap that this refers to is measured as of 5Y derived from spot derived from a 5Y expiry measured from today.
This is two different definitions. This is why the Schedule generator in my own fixed income library (https://rateslib.readthedocs.io/en/latest/api/rateslib.scheduling.Schedule.html#schedule) has two different parameters available, a swaps_align or swaptions_align version.
I have also had discussions with Bloomberg about this when they have been implemeting definitions for schedules. Local currency broker markets also use one or the other above or both if no-one religiously sticks to a variety. Bloomberg reported to me that they had various feedback for the use of both methods and by different client / dealer types. Ideally Bloomberg would like to provide both definitions but they have chosen to adopt the swaptions variety in  a first draft of what they are building. I am a swaps dealers so my own library defaults to the swaps align method.
Today: Friday 6th Jan 2023
Spot: Tuesday 10th Jan 2023

A regular 10Y ends on Monday 10th Jan 2033 and the swap has 10th rolls.

A 5Y5Y (Swaps Align) starts on Monday 10th Jan 2028 ends on 10th Jan 2033 and has 10th rolls.

A 5Y5Y (Swaptions Align) starts on Monday 10th Jan 2028 ends on 10th Jan 2033 and has 10th rolls.

All the above periods are regular periods when accounting for the regular adjustment of business days.
There is a more interesting example on that documentation link, since in this example there is no difference becuase nothing lands on a holiday at the 5y point.
Comment: Thank you very much for your assistance. That is very clear.


Does deleting iCloud photos affect them on devices?

Question: If I delete a photo from my iCloud will it also be removed from my devices that are connected to my account?
Comment: I think it would, if you use iCloud photo library. But it should also prompt you to warn you about that (I think).
Answer: Yes. This is a good way to clear out space in iCloud.They don't delete immediately, you can recover recently deleted files for a while, but they do disappear from connected devices and will eventually be deleted - any copies you export onto your computer (outside of the Photos app) will not be affected.  I back up older photos from the Photos app, by exporting them to a folder on my Mac, then removing them from iCloud, to recover space when my 5 GB of free storage gets full.


Is information the foundation of reality?

Question: More and more philosophers and scientists speculate that the basis of reality could be information, however there is something that does not come back to me in this line of reasoning: information is a resolution of uncertainty.  Information seems to make no sense when taken alone, and to say that information is the basis of reality seems to logically imply that uncertainty is actually at the ground.  Can anyone help me clarify this?
Comment: Simply understood, information is difference or contrast. The only reason 1 exists is because things that are not 1 exist. The only reason I exist is because things that are not I exist. So whatever you can measure empirically(with your senses) or reason about, you are performing a practice in distinguishing. The universe allows such a distinguishing to take place, hence it is reasonable to assume that the universe is made of information. And yet, information has the connotation of perception linked to it, which warrants further investigation.
Comment: Just as uncertainty/probability can be interpreted subjectively, as measures of subject's lack of information, and objectively, in terms of physical propensities (see [SEP, Interpretations of Probability](https://plato.stanford.edu/entries/probability-interpret/#ProInt)), so too can be the information. The proposers of information as the basis of reality, like Wheeler, Lloyd or Davies, opt for the objective interpretation. One can think of it as a form of idealism, but unlike the ideal of old theirs has quantifiable behavior and physical effects.
Answer: It is. Look at the uncertainty principle.
So, entropy is a multi-faceted concept mainly because, it applies where we can see all the moving parts, and also in matter where there are of the order 10^23 parts and many more states.
The information- or Shannon-entropy is defined in terms of signal loss on transmission through a channel, and this has been proven to be equivalent to thermodynamic entropy. In that technical sense, information can be defined as the inverse of entropy. And that is typically what is meant by everything is information - although information is also used in other senses even by those same physicists, causing confusion (for example, constraints, symmetries). The closest to the big bang we can see had the greatest degree of certainty about the state of the most matter; that is an equivalent description to saying it was in a high entropy state. It must be noted entropy is always relative, it is only meaningful in comparing states.
Entropy was long treated as a secondary property of matter, or mass-energy. But with relativity being about information propagation as limited to the speed of light, and quantum mechanics having the uncertainty principle defining quantum behaviour, information transfer & uncertainty is clearly fundamental to the behaviour of physical systems. It can be argued that modern physics is property-dualist, between mass-energy & information, and the expected resolution of those into a single description of mass-energy + initial conditions to provide a complete description in classical physics, has now shifted to an expectation that mass-energy will be subsumed into a more fundamental information space description. Mass is now described as interaction with the Higgs field. That just leaves space-time & the effect of mass on it, to unify all the known fields.
The programme to quantise the classical theory of gravity has failed, but space-time in quantum field theory only appears as unexamined background. So interest is now shifting to how space-time might be emergent from a quantum description.
Chiribella has proposed the 'purification principle', that increase of entropy is equivalent to the spreading out of information, or mixing of states that need to be known for a complete description. The conservation of information is increasingly speculated to be a universal principle by Susskind & others, because that would resolve the blackhole information paradox.  Blackholes seem to have the highest density of states possible, another way of saying maximum entropy, behaving as a kind of frictionless superfluid inside the event horizon. Time there behaves so strangely that it's likely observations will be needed to move forward, like through gravity-wave observatories.
There are many professional physicists who give the information-as-fundamental view short shrift, eg Sean Carroll. It is intuitively appealing, but can certainly be argued that it just restates what was always known, to do physics we want to compare states of systems at different times, so we gather & compare information, and contrast.
Comment: Why do you say Sean Carroll gives it short shrift? In [this post](https://www.preposterousuniverse.com/blog/2016/07/18/space-emerging-from-quantum-mechanics/) he discusses a proposal where spacetime is not fundamental but emerges from a picture where we divide a quantum state in Hilbert state into 'pieces' and then 'Use quantum information — in particular, the amount of entanglement between different parts of the state, as measured by the mutual information — to define a "distance" between them. Parts that are highly entangled are considered to be nearby, while unentangled parts are far away.'
Comment: @Hypnosifl: Yeah I think that approach is extremely promising. Here he is stating exactly what he is sceptical about though https://youtu.be/SRd0IY23baA
Comment: Thanks, it sounds to me like in that interview he is making the point that in our *current* best theories of physics (standard model of particle physics and general relativity) one can do physics perfectly well without making use of the concept of information, but at the end he seems to say he's open to the possibility that a future more fundamental/accurate theory might be fundamentally about information.
Comment: @Hypnosifl: Yes.. It pains me that he wasn't asked specifically about loop quantum gravity as information, or the it-from-bit doctrine, but presented with just a woolly pop science framing.


Is MSXML4 thread safe?

Question: I would like to know if I create an instance of Msxml2.FreeThreadedDOMDocument.4.0 in one thread, can I safely manipulate the instance from different threads using raw pointers?
Answer: Yes.  That is the point of the FreeThreadedDOMDocument.
cite: IXMLDOMDocument/DOMDocument

If you are writing a single threaded
  application (or a multi-threaded
  application where only one thread
  accesses a DOM at one time), then you
  should use the rental threaded model
  (Msxml2.DOMDocument.3.0,
  Msxml2.DOMDocument.4.0, or
  Msxml2.DOMDocument.6.0). If you are
  writing an application where multiple
  threads access will simultaneously
  access a DOM, then you should use the
  free threaded model
  (Msxml2.FreeThreadedDOMDocument.3.0,
  Msxml2.FreeThreadedDOMDocument.4.0, or
  Msxml2.FreeThreadedDOMDocument.6.0).

Is MSXML4 thread safe?


Can life occur from a fertilised egg cell, in which both the egg and sperm possess an extra copy of a chromosome?

Question: Patau, Edward, and Down Syndrome are all the result of either the egg or sperm cell possessing an extra copy of chromosome 13, 18, and 21, respectively. However, what would be the outcome if both cells possessed an extra copy? That is to say, if the fertilised egg cell is left with not three, but four copies of a chromosome?
Comment: I'm not qualified to answer this question, but knowing that a chromosome contains a whole lot of genes, that are basically the blueprints for stuff like as an example the hair color or eye color and so on... what if you have 2 chromosomes that contain different blueprints? will the body then destroy itself by trying to follow both blueprints or will one eliminate the other? Interesting question.
Answer: There are many ways to answer your question, I'll try a couple.
First, extra chromosomes in humans are commonly deleterious. However, there are known rare forms of tetrasomy that are not lethal, see Wikipedia on tetrasomy. Note that the causes of tetrasomy are rare events, so they are typically occurring in just one of the original gametes, not both; for it to happen in both would require a rare event paired with another rare event - not saying this is impossible, just less likely.
Polyploidy in other organisms, particularly plants, is both common and normal, see Wikipedia on polyploidy.


How to get to modwsgi 4+ on Centos7

Question: On Centos7, yum pulls in mod_wsgi 3.4 using a yum install.  I'm having some problems and multiple resources I have looked at regard this version as ancient and ask the users to upgrade to 4+.  I'm not finding the packages online nor any upgrade paths for CentOS like systems.  Has anyone gotten a higher version than mod_wsgi 3.4 installed properly on CentOS7 for an apache/python/wsgi configuration?
Answer: On CentOS 7 you can use a Software Collection to get a later version of Python (e.g. 3.6 or 3.8) both of which include mod_wsgi 4.5 and 4.6 respectively.
It's better though if you upgrade to CentOS 8 (you run a web site, why haven't you done this already?!?) where you can use module streams, a much more straightforward approach than the old Software Collections. In either case you can choose Python 3.6 or 3.8, both of which supply mod_wsgi 4.6.
Comment: Thank you!  I will give that a shot, good point on CentOS8

How to get to modwsgi 4+ on Centos7


Visiting Spain as non-EU family member (unmarried partner) of EU citizen

Question: I recently got a UK residence card on the basis of durable partnership with my Bulgarian partner. My card states that I am an EU family member and have EU right to reside.
Now we wish to travel to Spain for a holiday. The Spanish consulate website states that EU family members can travel to Spain with their EU partner as long as their UK card clearly states that they are an Eu family member, which mine does.
Does that mean I can happily travel to Spain without fear of being rejected and not let into the country?
Has anyone ever had experience with this?
Many thanks
Answer: The fact that you have a so-called "Article 10" card means that you can travel to Spain, under EU free movement law, without a visa.
Independently from that, when you travel to an EU country under free movement law, which is to say with your partner or to join your partner, you can only be denied entry on very limited grounds of public safety, public health, or public policy.  So yes, for most people it means that they can enter without fear of being denied entry, but it is still possible.


How do I log onto my mojang account on minecraft Pe?

Question: So I want to connect to servers and what not but it isn't working, do I need to log onto mojang first and if so how do I do it on the app?
Answer: You do not need to log into your Mojang account to access multiplayer in Minecraft: Pocket Edition. Your Google/Microsoft account is all you need in order to access multiplayer with friends through Realms or localised servers on your friends' device. You can also use the IP address and the port for private servers. But to answer the question posed, you do not need to log into a Mojang account to access multiplayer.
Answer: You can connect to a server by:-
1. Open Minecraft PE.
2. Click on play button and and press new button at the top right corner.
3. Then click on the button beside advanced at the top right corner which looks like this- +->
4. Now add Name, IP/Address and Port andearthquake click to the add server option.
5. Now you can connect to the server.
Comment: I don't think this actually addresses what the question was asking.


Measurement of 1 qubit in a two qubit system

Question:
I created two qubits in IBM quantum experience and measured the second qubit without applying any gate.
The result I got had a computational basis of 00 and 10. How does the measurement of the second qubit change the basis to 00 and 10? I have just started to learn quantum computing, so the question may sound silly.
Answer: Quantum computer are not perfect. There are certain limitation to quantum computers currently. Qubits are highly susceptible to noise and are error prone. A stray commic ray or thermal vibrations can change the results of the calculation. The Quantum computer must be maintained at very cold temperatures and if that temperature is not maintained then the qubit can have give faulty results. You'll notice that when ibm qiskit runs your program it runs the program several times, to calculate an average score to account for this quantum noise. You can change the number of time qiskit runs results to create a more accurate result.
If you look at the 'y-axis' of your results, you will notice this algorithm was run 100 times. (see under histogram). Looks like one in 100 times this algorithm gave an incorrect result.
Answer: If you had run this on the statevector_simulator then you will only see $|00\rangle$. However, due to hardware noise, which in this case coming out from the measurement error, you will have some $|1\rangle$ in your measurement on $q_1$. Depends on the hardware noise level, you might see 'more' or 'less' of $|1\rangle$ appearing in your result. If you want to improve your output probabilities result, just add more shots.
Update: Why would we would we only see the state $|00\rangle$ in the ideal world, like if we have used the statevector_simulator instead of the hardware?
The reason is because the starting/initial state on a quantum computer always start in the state $|000\cdots 0\rangle$.  That is, every qubit initialize with $|0\rangle$. And this state can be prepared with very high fidelity. In your case, you have two qubit, so your system is initialize at the state $|00\rangle$. That is $|q_0\rangle = |0\rangle$ and $|q_1 \rangle = |0 \rangle$. So now without doing any operation on this qubit, you ask the quantum computer, what state is the second qubit, $q_1$ in? The answer should be  $|0\rangle$ if you have a measurement process with no noise! Because the state the qubit $q_1$, $|q_1\rangle = |0\rangle$. There is no other answer it can give you. However, if there is noise presence, it might change this answer from a $|0\rangle$ to a $|1\rangle$ every so often, depending on the noise level of course. Say you ask 100 times, 95 of the time you will get the correct answer of $|0\rangle$ and 5 time it will return a $|1\rangle$ due to error. Think of this as like when you are driving in car through a scenic mountain area, then your friend call and ask if you want to come over to hangout. Because of where you are, the signal is not very clear, so eventhough you say "YUP", he/she might hear as a "NOPE" instead.... so if you have say"YUP", "YUP",.... "YUP" 100 times, he/she might pick up a "NOPE" 5 time out of the 100 time. This is what you see in your histogram plot... sometime the measurement process pick-up a $|1\rangle$ because of the noise in the measurement process as your friend has picked up a "NOPE" from bad signal.
Note that this should not be confusing with the state $|q_1 \rangle = \dfrac{|0\rangle + |1 \rangle}{\sqrt{2}}$... In this case, when you ask the quantum computer, "Hey QC, what state is $|q_1\rangle$ in? It will return you with a $|0\rangle$ or a $|1\rangle$ with $1/2$ probability. This is not because of the noise in your system. If you run this experiment $100,000$ time, you might get $49820$ time it will returns a $|0\rangle$ and $50,180$ time it will returns a $|1\rangle$. This is because your state $|q_1\rangle$ is in superposition of both $|0\rangle$ and $|1\rangle$, so when making a measurement, it will collapse onto either one of these state. And in this case, where $|q_1 \rangle = \dfrac{|0\rangle + |1 \rangle}{\sqrt{2}}$, the probability of collapsing onto the state $|0\rangle$ is 50% probability and the state $|1\rangle$ is also 50%. This is similar to tossing a coin if you think about it...
Comment: How is it that only 00 bais will be present in the simulator? I don't understand
Comment: the simulator simulates an ideal quantum computer. Therefore, no noise (accept you want to explicit add it).
Comment: @KSreerag I have updated the my answer to make it more clear.
Comment: @KAJ226 Thank you.
Answer: What you are seeing here is coming from the fact that quantum computation on real machines is not perfect.
In a perfect world, since you did not put any gates on your circuit, the state it should return is $|00\rangle$, the common initial state on any machine by default.
However, on real quantum machines, qubits can experience noise from the operations you are doing. Here, the $|1\rangle$ on the Qubit 1 comes from an error when measuring the Qubit, and there isn't really a way to completely avoid those errors when running quantum circuits on real machines.
Does that answer your question or do you need more explanation on something? Feel free to ask :)
Comment: Thank you for your guidance
Comment: By measurement, we are calculating the probability of that particular qubit becoming zero. right?
Comment: So if that's the case shouldn't the basis be 00 and 10(in case we are measuring the second qubit) in an ideal case(in the simulator). why is it only 00
Comment: By measuring one time, you recover a classical bit from the Qubit, see this as the Qubit that collapses on the bit, you don't get much information from this. If you want the probability of a Qubit state, you would want to run the same circuit multiple times and count how many times you have each possible state to approximate the probability of getting each one.
Comment: So in the case where I am running this on the actual quantum computer, I will get a probability of being in 00 and 10 states. right?
Comment: The basis will not change, it will be the same, what changes from one circuit to another is that the probability of being in each one of the basis state in the end, you will calculate the probability of being in each state. So indeed, in the case where you are on a actual quantum computer, you will have in this case the probability of being in either 00 or 10 due to measurement errors
Comment: So always the initial state of the system is 00 and in order to change this, we need to apply some transformations in form of gates. right?
Comment: Yes! A Qubit will always be at the 0 state at the very beginning, and if you want to change it you will have to apply gates. If you want, the [Qiskit textbook](https://qiskit.org/textbook/ch-states/introduction.html) explains this quite well I think, feel free to look at it and even work with it, it will show you theory and experience of quantum computation at the same time!


Was there any christian church that kept the Passover before the 1900?

Question: I was taught that after the Council of Nicea no christian church kept the Passover on the 14th of Nisan. Is there any truth to that? Is there a church in the middle ages that kept the Christian Passover on the 14th of Nisan? I've tried researching online but no luck. Thanks!
Comment: Kept Passover in the sense of doing a Jewish Seder? or in the sense of tying the date of Easter to the date of Passover in the Jewish calendar? EO date of Easter is still based on the Passover date, and thus sometimes a week ahead or behind Western Easter.
Comment: The Middle Ages did not stretch to 1900. Maybe get the dates sorted out. Do you regard only the religious groups that accepted the Council of Nicea as Christian?
Comment: @david brainerd: Tying the date of Easter to the Jewish Calendar.
Comment: @gideonmarx, yes, I understand that, it was just an example. By Christian I mean anybody that followed Jesus, even if didn't accept the Council of Nicea
Answer: As far as I know no Christian Churches except Jewish ones kept the Passover, as it is a Jewish holiday. You probably refer to the timing of Easter.
The Council of Nicaea ruled that Easter should be celebrated on the first Sunday on/after the first full moon on/after the vernal equinox. Sometimes it matched the Jewish Passover sunday and sometimes it did not, because the Christian system mixed both solar and lunar calendars to determine the date. For more info, see
http://www.timeanddate.com/calendar/determining-easter-date.html
Comment: There are some christian churches that keep Easter on the 14th of Nisan. I'm asking if there were any. I know now there are many


How to get file path without extension in Rust?

Question: Please help me to find an elegant way to get file path without extension; cut off file extension from path or something.
Answer: Check the Path::file_stem method. You can find an example there. It works at least from Rust 1.6.
Comment: Is there a method which gets the full absolute path before extension, not just the filename?
Comment: do you know the bahaviour if the file name has two extensions like "file.abc.xyz"?
Comment: @AndrewMackenzie the linked docs answer this: it returns "the portion of the file name before the final `.`"
Answer: Using the Path::with_extension("") method gives you the full path with a possible file extension removed.
Comment: This correctly answers the question, as if the input is a path with intermediate directories, this returns the full path, with the file_stem.


Html, handling a JSON response

Question: I have a page that comes back as an UnexpectedPage in HtmlUnit, the response is JSON.  Can I use HTMLUnit to parse this or will I need an additional library?
Answer: HtmlUnit doesn't support it. It can at highest execute a JS function. You need to check beforehand if the Content-Type of the returned response matches application/json and then use the suitable tool to parse it. Google Gson is useful in this.
WebClient client = new WebClient();
Page page = client.getPage("https://stackoverflow.com/users/flair/97901.json");
WebResponse response = page.getWebResponse();
if (response.getContentType().equals("application/json")) {
    String json = response.getContentAsString();
    Map<String, String> map = new Gson().fromJson(json, new TypeToken<Map<String, String>>() {}.getType());
    System.out.println(map.get("displayName")); // Benju
}

If the JSON structure is known beforehand, you can even use Gson to convert it to a fullworthy Javabean. You can find an example in this answer.
Answer: BalusC provided a good answer, but to answer the literal question, you don't really need an additional library: you can use Groovy's neat built-in JsonSlurper, e.g:
 def jsonSlurper = new groovy.json.JsonSlurper()
 def parsed = jsonSlurper.parseText(response.getContentAsString())
 println("Found ${parsed.TotalCount} records.");

to print out 1 for a response such as
'{"Records":[{"ID":"123","Address":"Zagreb",],"TotalCount":1}'

Html, handling a JSON response


Story identification: 60s tv episode where a man tries to drive out of a town but always end up in it?

Question: I thought this was a Twilight Zone or Outer Limits, but after reviewiing the lists of episodes, it doesn't appear to be. I remember it as black and white.
Answer: Could you be remembering the Twilight Zone episode Stopover in a quiet town?  Involved a couple and it was a train not a car but the idea is the same.  Only one train out of town (Centerville) and it brought you right back to Centerville.  Episode is from Season 5 and is available for streaming from Netflix.
Comment: It's almost certainly this.  It's an episode people remember and talk about, but often can't place.
Answer: This is almost certainly The Prisoner.
It's a British spy series, where in the backstory a secret agent that quits under tense circumstances is kidnapped and taken to a strange town which acts as a prison of sorts, and subjected to bizarre and violent behavior. In his many escapes, he's chased by what looks to be a giant beach ball.
Comment: The Prisoner was offbeat enough that I would think the questioner would have remembered the 'weirdness' and commented on it.  Maybe not although the giant beach ball is a signature of the series and hard to forget.
Comment: _The Prisoner_ was in color, though.
Comment: @Tango Good point, but that really depended on what sort of television you had. Ah, the joys of analog video signals!


Why don't dummy variables have the continuous adjacent category problem in cluster analysis?

Question: I know that if we use categorical variables in cluster analysis we would assume that the scale is continuous and we don't have this concept of distance between two adjacent categories.
But what is the difference when you use dummy variables? The zeros and ones will be used anyway to calculate the distances in the cluster analysis. In a nutshell, why don't 0's and 1's have this same issue? Any references about it?
Thanks
Answer: If you transform the category attribute to a 0-1 vector, you are in fact measuring the distance as "same = 0, different = 1", with no interim values. It doesn't gain you much actually, but it is at least less misleading. I strongly advise to control your results and algorithms with respect to this, as e.g. k-means will also produce "means" which are not sensible for binary attributes.
It harms less, because any two categories have the same difference. Say you have three categories, "red", "green", "blue":
<code>category  continuous    dummy
red           0         1 0 0
green         1         0 1 0
blue          2         0 0 1
</code>
When represented using a continuous variable, the distance "blue-red" is twice as large as "blue-green". The algorithm will thus consider these to be more different! This does not happen with the dummy variables, here the distance is in fact binary. You can achieve the same effect with a trivial categorial distance function
$$\text{dist}(c_1, c_2) = \begin{cases}0 & \text{if } c_1=c_2 \\ 1 & \text{otherwise}\end{cases}$$
Answer: Binary variables 0 (absent) vs 1 (present) misleadingly look like scale (metrical) variables while in fact they aren't. At best, one could classify them as ordinal. Logically, in order to venture label a scale interval or ratio the scale must have at least 3 levels. In dichotomous scale, we have just 2, so we never have clues to speak on how much "present" is greater than "absent". Since that, no sensible univariate or multivariate mean can be ever computed with binary attributes (as @Anony-Mousse said already).
Since it is inappropriate to compute means with binary variables it is inappropriate to use clustering methods which engage with cluster centroids (such as K-means or Ward). Still, any clustering that base itself on counting presence or absense is justified. There is a great number of proximity measures specially designed for binary data to be used in clustering. Even euclidean distance could be used unless cluster centroids are computed.


Replacing swamp cooler pads

Question: I have a AercoCool Pro 4800 swamp cooler roof unit and need to get new rigid pads for it. Do the pads need be specific to the brand according to the cooler's spec sheet, or can I use any pad that is the correct dimensions?
Answer: The pads are not a big deal you want ones that fit and are rated for the filled weight (filled weight of the revisor or tank) . If the pads are not heavy enough they will not support the unit and may cause damage to the structure.

Replacing swamp cooler pads


Shelf brackets extend past the shelf

Question: I am a little confused. I purchased shelf brackets in the exact size of the previous ones I had for this shelf. The new brackets however extend a bit further past the shelf itself ( not the depth going down ) but the width. Is this an issue? I plan to put hanging plants and could hide the extending piece of the bracket but is there a safety concern with this. I plan on putting very light items. I am just as to confused as to how they say they are the same size but aren't really.
Comment: Can you include a few pictures in your question?
Comment: Pull the shelf forward until flush with or just past the bracket. Now check how large the gap is from the wall to the back edge of the shelf. Most likely it is not large enough to cause concern unless you are setting very small items near the back of the shelf.
Answer: If they were the "exact size of the previous ones" you may have them rotated "the other way" - many shelf brackets are not the same length on both legs, so you may have had the longer leg on the wall and the shorter leg on the shelf in the previous installation, and the longer leg on the shelf this time.
Flip them around and see.

Shelf brackets extend past the shelf


How is SAML solving the cross domain single sign-on problem?

Question: Let's say I have two websites that live on separate domains, and their service providers both talk to the same identity provider on a third domain. I log into the first website and authenticate, and now I decide to visit the second website. The second website comunicates with the identity provider so I don't need to log in again to access my account. How is this achieved using SAML? Is it possible to use cookies in this case?
Answer: It actually can be a cookie, because it needn't be associated with the service provider at all, only the identity provider.   All either of the two service providers are going to do is make the authentication request to the identity provider, so the process for an unauthenticated user is going to be the same for sp.example1.com as it is for sp.example2.com.
However, when the first request is made from sp.example1.com and the user is redirected to sso.example3.com, the user will login to sso.example3.com and can then set a cookie for sso.example3.com.
Then, when the user visits sp.example2.com, it too will redirect the unauthenticated user to sso.example3.com, but this time, the browser will have a cookie to send along with the request from the last time the user visited sso.example3.com, even though that visit was initiated by a different service provider.
Thus, the cookie from sso.example3.com can identify the user as already authenticated, and the identity provider can continue the process of issuing an assertion for the user to sp.example2.com without requiring the user to complete the login workflow again.
Answer: It is possible using cookies.
Cookies are nothing but small pieces of data (name-value pairs) that is stored in your browser by the web application you are communicating with. Every cookie has a domain associated with it and a cookie belonging to example.com can not be accessed by abc.com.
It is important to note that whenever browser makes an HTTP request to a certain domain all the cookies associated with that domain are also sent along with the request to the server.
In SAML terminology
Identity Provider (IdP) - Provides authentication as a service
Service Provider (SP) - Relies on IdP for authentication of its users
SSO using SAML : let us say there are two services SP1 and SP2 the user wishes to access.

User visits SP1 and tries to log in. SP1 sends an authentication request to IdP and the user's browser is redirected to IdP where he enters his credentials. After successful authentication the user is again redirected to SP1 and IdP sends an assertion to SP1 which contains authentication information. Now the user is authenticated and may use the services of SP1. In this case the response coming from IdP also contains a cookie to identify the user. This cookie is stored in the browser.
Now the user opens another tab in the browser and tries to access SP2's website. Again as he tries to log in the browser is redirected to IdP and with this redirect the cookies set by the IdP are also sent. The IdP receives the cookie and sends an assertion redirecting the browser back to SP2. The user is logged in to SP2 without needing to enter his credentials again.
Answer: I believe that mod_auth_openidc implements this feature as "Session Management" by using iframes.Here
But I don't know if there is any other better/alternative solution with other SAML/OpenIdC products
Answer: the challenge is session cookie, as we know we will set session cookie or time based cookie in SSO website, but as usually user is visiting the SP1 and SP2 site, both the session cookie and time cookie will be expired during the visiting. how do we keep the login status? try ajax call to SSO website at backend? that's the one way I can think of.
Comment: Facing the same issue. Did you find a solution


Vimium: How to select a frame (e.g. Reddit comment) in the current viewport?

Question: I'm a power user of Vimium, but I haven't figured out how to achieve this:
When I'm browsing, say, Reddit, using "j" and "k" keys to scroll. In the middle of the browsing, there would be some comment that's the root of a large tree (sub-comments). I'd like to collapse the entire tree so I don't have to scroll down many pages to skip over the tree.
This is easily done using mouse (just click on the line on the left), but since those lines are displayed via javascript (I think), there's no way to click on them via Vimium / keyboard.
I went over the Vimium doc and haven't been able to find this shortcut to select the entire frame / div of a single comment, although I did accidentally pressed on a key that did just that when I was browsing Quora when I moved my keyboard, but I then pressed on every key on the keyboard and wasn't able to reproduce it.
I know Reddit has its own shortcuts, so, say, if I disable "j" and "k" in Vimium for reddit.com, I can use those keys to iterate through comments, but it still doesn't do what I want because it's limited in these ways:

You have to start from the very top. So if you are browsing in the middle and see a big tree and want to collapse it, you have to move the selection from the top one bye one;

I don't want to have to iterate through all comments when I browser in order to select the one I want to collapse, I just want to select the one in my viewport;
Answer: The key-binding gF will focus your browser to the top frame. After that you can use f to navigate frames (this is in Vimium-C)
Comment: Nice! I was having this issue with Trello (couldn't scroll modals). vimium-c handles this out of the box. Switched!


Micro services communication among them

Question: I am converting a monolith to micro services architecture using RESTful apis using C#. I have identified various micro services that will completely represent my monolithic application.
One important service is a configuration service which holds important configuration information which would be needed by the remaining micro-services.
What is the best way for the services to communicate with the Configuration service?Can I directly invoke the configuration service URL from other services using HTTP?
I have looked into other approaches like RabbitMQ, pub/sub, but i believe that these approaches are more suited for use cases where broadcasting of information is needed to multiple services.
What would be the best approach for communication between services in the above case?
Comment: Please read the help center articles, before posting. Cross posting is very discouraged. Only post on **ONE** (the most suitable one for your topic) stack exchange Q/A, not multiple
Comment: Have you considered refactoring your current application rather than going straight to microservices? The work you have done to identify logically separate areas of code can still be used, and you dont have the deployment / communication / performance overhead that microservices introduce.
Answer: May i suggest using gRPC. It's relatively easy to build services with it and you get a lot of benefits:

you have a strong api contract and strong api governance as the api spec is put apart from the code
you can generate client/server code in many languages
it's well supported with current asp .net  core technology

One word of caution, think twice before moving to the all new hot stuff called microservices. We tried microservices, but ended up with a totally over engineered distributed application not solving any real problems... ;-)
See here why the istio team is switching back.
Answer:
I don't see why you see RabbitMQ as a broadcasting solution, RabbitMQ is a Messaging Bus.
I think it's a very good solution for inter-service communication.
For a configuration service, why not use Observer Pattern where your apps read the initial configuration and then be notified whenever a config change (that matters to them) occurs
Comment: He didn't say RabbitMQ was a broadcasting solution, he said it was a pub/sub. Which, according to their documentation, it implements that pattern.

In your response, try to focus on the question - what is the best way for the services to communicate with the configuration service,
Comment: @MartinK: Question reads differently: _I have looked into other approaches like RabbitMQ, pub/sub, but i believe that_ its an enumeration, RabbitMQ along with pub/sub (assuming the interprocess pattern for message communication - everything else makes no sense since there is no product named pub/sub afaik) and pub/sub as a pattern is broadcasting like: You fire up an event and don't know if anyone will handle it or if its. MessageBus on other side has more stuff (routing, persistance) that a simple pub/sub pattern doesnt
Comment: @Tseng exactly how I read the question, thanks
Answer: Assumptions:

You have a sound architectural vision for moving from the
monolith to micro services
A lot of these micro services are processes that has a life cycle and are long running
These micro services need to know when a configuration data entity/attribute is changed, but they do not change configuration data.

I would suggest that the primary IPC (inter process (service) communication) is REST with JSON.
So when one of these other services are woken – called for the first time it calls (REST API) the configuration services for "all" configuration data – that is available/needed.
And when needed it could check for a specific configuration data through another REST API.
Issues to be aware of is the timing, update cycle of all / different configuration data. So when other services are trying to read a configuration data being updated they will wait and the REST API will return when the update is COMMIT.
If they need to know instantly when a configuration data is changed then you in addition will need to use preferably a MQ solution most of them provide a REST API eg. https://activemq.apache.org/rest. So the configuration services publish on a specific message que a topic of a changed configuration data and all services subscribing to that que/topic gets notification to pull that new configuration data.
If you need to scale (out) the configuration service, i.e. running several instances of it then the solution will become more complex and you will need a different data management approach.
A good source for these type of pattern and variants are Chris Richardson – his site https://microservices.io/ and his book microservices pattern https://www.manning.com/books/microservices-patterns

Micro services communication among them


How to hook up generator transfer panel when main breaker is on different panel?

Question: Is there a way to add a transfer switch to a main panel that does not have a main breaker? My main breaker is outside near the meter. I would like to have all circuits available for my generator. I would obviously have to watch the load but instead of switching over certain circuits to a different panel I would like to just individually turn on certain circuits or off certain circuits. I have included some pictures of my main breaker, main panel and a sub panel.
Comment: Basically a duplicate. https://diy.stackexchange.com/a/37031/18078
Comment: The marked duplicate is *not* a good match for this question. In particular, this question has a real solution by adding a main breaker to the subpanel, provided OP can do without the other circuits from the actual main panel (which seems likely but not 100% definite). The marked duplicate question talks about going backwards from the subpanel to feed the main - that's an absolute *can't do that no matter what* situation. Very different.
Answer: Two possibilities, and a big problem.
Turn the inside subpanel into a "main" breaker panel
I'm betting that the inside "main" panel is convertible from lugs to main breaker. It is likely fed from lugs off of the actual main panel outside - i.e., protected by the 200A main breaker, so the original installer saved a few $ by not including a main breaker in the inside subpanel. But you can likely (can't tell for sure without more details) convert it to a "main" panel by adding a main breaker. Then you replace a pair of breakers at the top (left or right, depending on how the interlock is designed) with a locked down double-breaker and install an interlock and run cable from the breaker to an inlet for the generator. You can then run any loads using the generator except for the Pool House, Pool Pump, 4 Ton Upstairs A/C and the mystery breaker.
I am pretty sure the mystery breaker is not a feed to your inside big panel because 60A is simply not enough for that panel.
You will need to clear some space in the panel, either by installing some tandem breakers (where appropriate, watch out for MWBC and other issues) or consolidate some 15A or 20A breakers where acceptable to do so (e.g., can't eliminate dedicated bathroom, kitchen, laundry circuits).
Interlock in the Main Panel Outside
Investigate the upper-right mystery double-breaker. If it is not currently connected to anything or is connected to a no-longer-used circuit, replace it with a locked-down double-breaker and install an interlock and generator inlet. You can then use the generator for any circuits.
PROBLEM: GROUND/NEUTRAL MIXING
The big panel inside is wired as if it were a main panel, in that the grounds are placed on the neutral bars. You can only do that in a true main panel. This isn't even a grandfathered "used to be main and now sub" situation, because if it were then there would be a main breaker in the inside panel, and there isn't one. It could also be OK, in some cases, if the outside panel were used solely as a service disconnect, but it has Pool and A/C, so that loophole doesn't work either.
INSTALL GROUND BARS AND MOVE THE GROUND WIRES FROM THE NEUTRAL BARS TO THE GROUND BARS. This is independent of the generator issue - it is a significant code violation.
Comment: And the "sub" panel needs the separation of ground and neutral as well.
Comment: The sub-sub-panel apparently doesn't even have a neutral connection from whatever supplies it, if I assess the somewhat jaw-droppingly bad wiring correctly. Apparently it's backfed through one of the breakers, and none are tied down, so there's that, too. Hack job all around, and really doubling down on using ground as neutral inappropriately.
Comment: Retrofitting a main breaker to the "main subpanel" would be a great approach if the pool and other things there will never be critical loads.
Comment: @Harper-ReinstateMonica I can't imagine the pool breakers being critical loads. Though my imagination may not be so good :-) But the A/C is an interesting part - as you know I like my A/C. But that's on a 60A breaker, so if sized correctly that's got a peak load higher than 48A, which would be pushing it on typical generator size, with the exception of a true whole-house generator.
Comment: Correction, peak higher than 40A (max. for a 50A breaker). But still, that's a lot to throw on the generator along with the other critical circuits.
Comment: After looking closer and reading here. Yes I did indeed mislabel main panel, as technically outside is main and the inside is fed from that. The little sub panel after closer inspection was set up to plug a generator into. No way correct, the sun is fed from inside large panel (240/50a breaker) to the first breaker inside little sub. A makeshift generator plug feeds second breaker, then sipplies one room of lights, fridge and hot water heater on other breakers.
Answer: We can cross off the 6-8-10 circuit style of obsolete transfer switch that we love to hate around here.  #1 A transfer switch can't feed 2 panels.  #2 A generator can't feed 2 transfer switches.
Now that thing you call a "main panel" is actually a subpanel that is improperly wired for post-1999 subpanels.  The main panel is the one with 5 breakers that you are calling "main breaker".
Given your desire to choose any circuit at any time, your best bet is to install a generator interlock out on the "main breaker". You have 4 dead breaker spaces there.   The top 200A breaker turns everything off, yes? It's not back-fed (making it a Rule of Six panel)?
As manassehkatz points out, your "Main subpanel" appears to be a "convertible" to which a main breaker can be retrofitted.  You don't need a main breaker there for a breaker, but that plus a breaker and a generator interlock would be a cheap way to get a "whole house except for outside loads" transfer switch.
Also your service appears to be overloaded.  The "Main subpanel" should have neutral and ground separated and double-tapped neutrals separated.  The "sub subpanel" has too many defects to list here.
Comment: Currently going to look at what the mystery breaker outside is, 240/80 amp breaker. No clue though what it runs. I agree that if that is empty this could be a place to add the generator plug.
Comment: Also seems I will have the electrician do some rewiring in the panels as I could easily see that this looked not quite right. Might as well get it sorted now. House has had some remodels.
Comment: @Lefebvres090428 Yeah, that subpanel is probably a "do-over from scratch" given the countless horrors I see.  Seize the opportunity to use a subpanel with many, many more breaker spaces, even another 40-space isn't absurd.  Spaces are cheap.  Link the two panels with a few metal conduit pass-thrus, easy way to pass circuits through.  I'd go Square D HOM as you'll have interchangeability with breakers in the main panel.  Square D QO is a very nice panel but breakers are twice normal price.


Database distribution in AlwaysOn

Question: Good morning all,
I have an on Always On SQL server configuration where transactional replication is configured
If I open SSMS I find that the distribution database is set to AlwaysOn on then I cannot find the synchronized word.

thanks
Answer: I would not rely on Object Explorer (or the AG dashboard) in SSMS to determine the status. Use the DMVs directly (or create your own dashboards against them). Something like this:
SELECT
  d.name,
  AGName = COALESCE(ag.name, 'N/A'),
  drs.synchronization_state_desc,
  ar.replica_server_name
FROM sys.databases AS d
LEFT OUTER JOIN sys.dm_hadr_database_replica_states AS drs
  ON d.database_id = drs.database_id
LEFT OUTER JOIN sys.availability_groups AS ag
  ON drs.group_id = ag.group_id
LEFT OUTER JOIN sys.availability_replicas AS ar
  ON drs.replica_id = ar.replica_id;

I suspect this specific limitation is just that they didn't add the display sync status logic into the code path that renders the System Databases node. The fact that is it missing is documented here, but without an explanation why:

SSMS does not show Distribution Database as synchronizing/synchronized, when distribution database is added to an availability group.

Database distribution in AlwaysOn


Is there an Ethereum javascript library to work with creating and validating addresses?

Question: There are a bunch of ethereum sites with alot of js functionality already, but how did they do this when there is no js library that I can find? Is there a javascript library for working with Ethereum?
Comment: The Ethereum Elements package for Meteor has validated address input. https://atmospherejs.com/ethereum/elements
Answer: The EthereumJS project includes many useful JS libraries. In particular, for addresses, you can use the EthereumJS-Wallet library.


Java efficient implementation of a finite field (for cryptography use)

Question: Is there any popular robust implementation for a finite field in java? (An implementation of prime fields ,i.e. $GF(p)$ might also be good.
Answer: You can check Rings Java library (http://ringsalgebra.io). It has quite efficient support for Galois fields $GF(p, k)$ (both for small and for arbitrary large $p$).
Answer: You could look at Givaro c++ library for finite fields (I used it, and it is quite okay, and source code is accessible), and try to adapt it to java, because for java I am afraid you have nothing analogue. (Last time I looked for this, I found only some buyable library, and for $p=2$ only.)
Comment: Can you post a link? C++ might be okay also, I can use JNI. Forgot to mention, I need to use it with very large fields (for cryptography matters), does it efficient enough?
Comment: I don't know if it would suit your need, as I was using it to construct quasi-numbers. A link ? Google is your friend, and typing "Givaro c++" in it may surprise you.