Noise cancellation by averaging multiple images together

Question: As the title suggests , I want to know how noise cancellation is achieved by adding multiple images together . I know the theory behind it , but simple adding the pixel values of 100 noisy images of the same sample would simply produce a white image . Can anybody elaborate , how it is normally done.
Comment: You're not *adding* them together; you're *averaging* them together.  You have to divide by the number of images in order to not clip at white.
Comment: @endolith : You are right.I mae a mistake
Answer: This works simply by virtue of the central limit theorem. For a given pixel, you are given 100 observations of its true value + random noise; and if you assume that the noise has zero mean, then the average of these will have a normal distribution centered at the true pixel value, with a variance decreasing as more observations are added. The central limit theorem also tells you that this is a rather terrible denoising method: for a gain in SNR of $6dB$ (reducing noise by a factor of 2) you have to increase the number of averaged samples by a factor of 4.
Regarding your problem, are you sure that you are averaging (dividing by the number of images) rather than just summing? And are you sure that you are using the correct data type for your computations? These are implementation/programming questions and are out of topic here.
Comment: You don't need to do this in the Fourier domain, this would be a waste of computational resources and the result would be the same (Since the Fourier transform is a linear operator, the average of the Fourier transforms is just the Fourier transform of the average...)
Comment: Programming depends on theory , I want to implement the theory . Its not that hard to just add two images pixels by pixels . But for cancellation , in a a normal image , you need to have some pixels that -ve in value , others +ve . On what basis , do you make do you separate pixels values , to take two polar values .
Comment: Just another comment , do I have to do this in the Fourier domain , if so , I need some study .
Comment: Noise canceling through summation assumes that the noise has zero mean. If this is not the case the result of the averaging process should be, to the limit, the original image + the mean of the noise. In any case, this should not be a white image.
Comment: Yes, I figured out my mistake . Thanks , btw.


How to find the sides of an equilateral triangle given all angles.

Question: How do I find the length of sides and the height of an equilateral triangle when I only know the three angles and the area.
The area is 50.3144 and obviously all the angles are 60 degrees.
I'm in grade 10 so I don't want some crazy formula to figure this out, I've looked everywhere on the internet but all websites talk about SAS, AAS etc. but I have not been given any side length just the area and angles.
Comment: Remember I don't know any side lengths
Answer: Let the triangle be $\;\Delta ABC\;$, say with $\;A\;$ the upper vertex, and let $\;D\;$ be the midpoint of side $\;BC\;$ , say. Then, $\;\Delta ABD\;$ is a straight $\;30-60-90\;$ triangle , so $\;|BD|=\frac12|AB|\;$ and $\;|AD|=\frac{\sqrt3}2|AB|\;$ (use Pythagoras Theorem)  , and thus the whole triangle's area is
$$\frac{|BC|\cdot |AD|}2=\frac{|AB|\cdot\frac{\sqrt3}2|AB|}2=\frac{\sqrt3}4|AB|^2\stackrel{\text{given}}=50.3144$$
So now just get (fill in details)
$$|AB|=\sqrt{\frac{4\cdot50.3144}{\sqrt3}}$$
Answer: Well there is simple formula to find the area of an equilateral triangle.
$Area=\frac{a^2\sqrt{3}}4$, where $a$ is the side. Now you do know the area. Compare it to this formula and and find $a$.
This formula can be easily proved in two simple ways that you might know. The first is using basic trigonometry, where you drop a perpendicular from a vertex to the opposite side and sum the areas of the two triangles that you get. And the second is using the semi-perimeter method. If you are unable to prove it, you could very well just remember the formula.
Answer: The area of any triangle is given by the length of the base times the height divided by 2.  You are trying to calculate the length of the base.
If you draw your triangle you will easily see that if you bisect it vertically you have a right angle triangle with base $b/2$ and hypotenuse $b$.  You can see by pythagoras that the height = $(b.\sqrt{3})/2$
You can then substitute the height and area into $a=b.h/2$ to find the base.
$a=b^2.\sqrt{3} /4$
$b=\sqrt{4a/\sqrt{3}}$
which is about 10.77


What Biology topics are linked to the Nitrogen Cycle?

Question: What other educational topics are linked to the Nitrogen Cycle? I am a Science teacher, and I need to organise my lessons. Thanks!
Comment: As phrased this is currently *very* broad.  You say "other" but don't say what you've already considered.  What work have you done so far?
Comment: @justin other topics may be symbiosis , root nodule formation,chemical "talks" between rhizobium and legumes. Examples of symbiosis like mycorhhizae can also be given.
Answer: The nitrogen cycle is a highly biological process. Nitrogen gas is ~75% of the earth's atmosphere and N2 is the most chemically stable form of Nitrogen for conditions in the Earth's crust.
Nitrogen is one of the four most essential and universal elements to terrestrial life (Carbon Hydrogen and Oxygen being the others).  Nitrogen fixation, the name given to the various processes which make chemically reactive forms of Nitrogen available to living things. Ammonia (NH3 / NH4+) and Nitrites / Nitrates (NO2-, NO3-) are chemically unstable compared to N2 and the conventional biosynthetic processes in the cell can use any of these forms to make proteins, nucleic acids and other biologically active molecules necessary for life.
Ammonia and similar compounds like Urea come from the biological byproducts of  living cells - waste.  These are readily recycled in the soil by plants and microorganisms and I imagine some animals and insects.  Nitrogen is a limiting resource for living things and most biomes are pretty efficient at recycling reduced nitrogen from primary (NH3) secondary (NHR2), tertiary (NR3) and quaternary amines (NR4).
But the biosphere has a great demand for bio-useful nitrogen and in most places on earth in deep water and soil microorganisms can break down N2 directly into nitrates/nitrites. This happens deep underwater or underground because the enzymes which perform this activity are delicate and ruined by O2.  This process is entirely performed by anaerobic microorganisms. In recent decades, the ecological importance of subterranean microbial communities has become better appreciated for the complex structure and ecological roles it plays.
An interesting side note to this is that up to the early 20th century, the growth of life and human civilization was really limited by the intense labor required to grow food.  While hydrogen oxygen and carbon are essentially free - obtained from water, atmospheric oxygen and CO2 by plants, Nitrogen was the limiting factor in many cases to growing more crops or animals for food.
The Haber process, which converts nitrogen and hydrogen gas under high temperature and pressure into ammonia over a catalyst was such an important discovery - it allowed the industrial preparation of effective fertilizers and was instrumental in creation of the green revolution.


Migrating color swatches from PS to AI

Question: is there a way to move my color swatches I gathered while working in Photoshop to Illustrator (both versions are CC)?
Answer: Yes. In photoshop from drop menu choose "save swatches for exchange", choose destination and name. Then in illustrator Open swatch library "other library" and point to *.ase file you created.
Comment: Thanks mate, it really helped a lot. And, on a sidenote: Portugalia jedzie do domu!
Answer: You can save swatches to Adobe CC library (See this link for a full introduction to using the CC Library). This library can save various assets but one of them being swatches which you can use on various Adobe programs. The swatches will sync whenever you make a change to the swatch.
There are many ways to add swatches to a library.
1) Add assets from the page by clicking the "Library from document" button
2) Add Foreground Color button
3) Drag a swatch from the swatches panel into the library window
4) Make or download swatches from https://color.adobe.com/

Migrating color swatches from PS to AI


How transfer documents (not music/video/photo) from Mac to Tab S 10.5?

Question: HELP:  Really stuck just can't seem find a solution to move documents (powerpoint etc) from my Mac to a new Galaxy Tab S 10.5 - nothing seems to work - any suggestions please (of course i can fall back on dropbox I suppose but why can't the device be seen as an external memory source same as the Galaxy Note??
Answer: The Galaxy Tab S 10.6 seems to use MTP as USB connection mode. Since Mac OS X doesn't support MTP, your Mac can't see your device. I suppose that your Note has Micro SD card installed, and your Tab doesn't. If your Tab has a Micro SD card, it might be able to connect with your Mac.
For your question, I suggest using Airdroid (the first version) or anything similar to it. Since it transfers your file via LAN, transfer speed is a lot faster. Hope this help ;)
Comment: Thanks for that yep the Tab also uses the micro-SD card - i've given airdroid a try seems to work well, thanks so much


Are sidewalks on a university public or private property?

Question: Specifically, am I allowed to travel on sidewalks on a university when I want, as I would be able to do outside of the university (which I know to be public property).  If the state in question does not have a "stop and identify" law, am I required to provide identification if being detained on a university sidewalk?
Comment: Is this a public or private university?  In what state?
Answer: You have two questions going here. One is "are sidewalks on (state) universities public property", and the other is "when do I have to provide identification in a state with no stop and identify law". I will focus on the second question. As it happens, property ownership is not relevant to that determination. The universal fact is that only a peace officer (variously identified) can force you to identify yourself, no matter where you are. In Ohio, which has such a law, the law requires you to give name, DOB and address if they suspect you and you are in a public place. Being in Kroger is being in a public place, even though Kroger is private property. Alabama likewise allows officers to stop and question a suspect in a public place. Arizona doesn't even limit the requirement to "public places". In Illinois, you will not be convicted of obstructing. That is because 725 ILCS 5/107-14 a peace officer "may stop any person in a public place" and "may demand the name and address of the person and an explanation of his actions". However, they forgot to include a part where the suspect has to answer in the statute. As far as I know, Washington state has no law allowing such questioning and again as far as I know you can refuse to respond. So: if you are a suspect, and the state has no stop and identify law, they cannot require you to identify yourself, and then in some states, you would even need to be in a public place.
And then there is Arkansas, where it looks like failure to identify can be taken as evidence of loitering (one would have to read the Arkansas case law to see if it's really that bad).
Comment: All universities are public places, including universities owned by churches. Trespassing is not limited to private property. However, walking on a sidewalk in a public place is not trespassing, unless there is an indication that you are not allowed on the sidewalk. A public place is not the same as public property: private property can be a "public place", e.g. a shopping mall.
Comment: In the state I am in (Michigan), there seems to be no statute requiring an individual to identify himself unless he is arrested.  The first question is thus pertinent to the second.  Are sidewalks on universities public or private?  If they are private, then an officer might be able to charge for trespassing, for example.
Answer: Publicly owned <> Public Space
All land is owned by someone. If the owner of the land is a government then the land is "publicly owned" otherwise it is "privately owned". Further, that land may be leased to someone else, in which case the controller of the land may be different from the owner of the land.
A state university is not an organ of the state government; they merely source (some) of their funding from the state but are legally independent, usually structured as trusts or public corporations. In that sense the land they own is "privately owned".
Notwithstanding, whether an area is a public space is totally independent of who owns it. The White House is publicly owned but it is most certainly not a public space. In contrast, a shopping mall is (generally) privately owned but the publicly accessible spaces are public spaces while the mall is open.
You are allowed to walk on the university's sidewalks when and how the university decides you can. If they decide to allow members of the public to do so then those areas are public spaces, if instead they erect fences and gates where you must swipe your student or staff ID to enter, they are not public spaces.


What does splitter do in logisim?

Question: I have just started learning logisim, so i have a very simple question. My question is what does splitter do. Whats its function and how can we actually implement it(like on breadboard or trainer board)?
Thanks in advance
Answer: It's an organizational thing, basically.  It takes a multi-bit bus and splits it out into individual bits.  Just a change in representation in the schematic.  There is no logical function to a splitter, only interconnect.  You would implement it on a breadboard with wires.
Comment: Actually, that's a really good analogy. A breadboard is merely a big bus. And wires connected to the breadboard does exactly the same thing as splitters.
Answer: You can check the "Library Reference" in the Menu bar of Logisim for the definition of the splitter. It's actually a very good tutorial of the thing.
It just basically allows a representation of for example 32 bits into a single wire. Just so it won't be messy. And the other components like the multiplexers in Logisim would require you to use splitters since you'll have to give it an input of 2 bits with the use of a single wire for the selector.
Also, splitters can actually be used to have an input of multiple wires representing multiple bits with an output of a single wire representing all or a part of those multiple bits. And it can also have an input of a single wire of 1 or multiple bits, and output several wires, with each wire representing one or multiple bits.
It's basically just a way to make your circuits cleaner. You can implement it with wires for breadboard, the same way you could do so for the other components in Logisim like the shifter.

What does splitter do in logisim?


Saboteur 2 - Restrictions on playing "trapped!" in the end of the round

Question: Are there any in-game restrictions on playing the trapped! and the tool-breaking cards in the end of the round? For example, can I play the trapped card as my last one on a player who has no more cards?
Answer: In the rules there are no special restrictions for the new action cards.
In the normal gameplay:

When it is your turn, you have to take one of the four following
actions:

Place a path card in the tunnel maze then draw 1 card.
Play an action card then draw 1 card.
Discard two cards from your hand to remove a card in front of you then draw 1 card.
Pass and discard 1-3 face-down cards from your hand then draw 1-3 cards.

Then your turn is over and it's the next player's turn.

There is also no restriction mentioned for the trapped card:

Trapped! (3 in the game)
Play this card face-up in front of another player of your choice. This
player is trapped and cannot play any more path cards. If a player is
trapped when the round ends, they don't get counted as one of the
winners and don't get a cut of the treasure.

So yes you can play an trapped card on a player that has no cards in hand. It literally traps the player, but he or she can be rescued by another player using the "Free at last!" card.


Recommended foods for before surgery?

Question: For an appendisectomy, what foods would be best to eat pre-op? What foods should be avoided or could make the surgery more difficult? Although there is no appetite and the only thing eaten in the past two days is watermelon which was promptly vomited. There is also a constant intake of fluids with electrolyte tablets. Please, what foods would be recommended and which ones deterred?
Comment: Appendisectomy (aka appendectomy) is a fairly short, simple procedure so it's not going to make much difference. And since you're unable to hold down solid foods now, the answer is probably "none." I don't know why they're waiting to do the procedure, but a few days without food won't hurt you.
Comment: Hopefully a Dr is going to perform the operation.  I would ask them.
Comment: @Paparazzi Yeah, it will be a doctor - assuming this is in the US.
Answer: In general, the best thing to eat before surgery is absolutely nothing.  This is done to reduce the risk of aspiration pneumonia, as your swallowing reflex doesn't work right under general anesthesia.
Your doctor may have specific instructions to the contrary, so ask them.

Recommended foods for before surgery?


What does "racking in cash" mean?

Question: What does it mean to "rack in some serious cash"?
Does it mean to make money quickly and making loads of cash?
Comment: You probably have misheard  or misread 'raking in cash' meaning you are earning cash like you are raking leaves in quantity.
Answer: Yes. It means making a lot of money fast.
Rake in means

Fig. to take in a lot of something, usually money.
"Our candidate will rake votes in by the thousand."
"They were raking in money by the bushel."

Rack up means

Fig. to accumulate something; to collect or acquire something.
"They all racked a lot of profits up."
"We racked up twenty points in the game last Saturday."

What you heard is probably a mix of these two.
Also, Serious means

Informal Of considerable size or scope; substantial
"a serious amount of money."

Definitions from The Free Dictionary
Answer: To rake in means:

to earn or get a large amount of money: 'He rakes in over $200,000 a year.'

"Rake in some serious cash" - Making a lot of money quickly and steadily.
She's really raking it in (= making a lot of money).
To rack something up means:

to gradually get more points, profits, etc.: 'He has racked up 450 points in three months.'

[Cambridge Online Dictionary]

What does "racking in cash" mean?


What characteristics do Alpha/Beta wolves have in the Twilight series?

Question: I watched Breaking Dawn Part One, where they used the term Alpha Wolf for their leader. But how can one become an Alpha wolf in the Twilight series, and what are the differences between the Alpha and Beta wolves? It doesn't get explained or maybe I missed something. Is this explained in Breaking Dawn Part Two or the novels etc?
Answer: In Twilight, the leader of the tribe is the Alpha Wolf.
The second in command is referred to (by Bella, not the shifters themselves) as the Beta Wolf.
How can become a Alpha wolf?
Either by election, or by lineage.
Alpha Powers
The main power an Alpha gets is the "Alpha Voice".

The Alpha voice is an ability that only a genetic or elected Alpha
  shape-shifter possesses. It is unknown how the Alpha voice works and
  whether an Alpha shape-shifter can use his Alpha voice to command his
  pack members in both human and wolf forms. Once an Alpha shape-shifter
  gives orders to members of his pack, his orders are obeyed blindly.
  The pack members cannot directly disobey commands even if they are in
  disagreement. This ability, however, is limited to pack member and
  cannot influence another Alpha shape-shifter.

The Beta Wolf can also do this, but can be overruled by the Alpha.
In addition an Alpha can also communicate with the Alphas of another pack telepapthically (like how they can within their own pack).
Comment: The "Beta" wolf (the "first") cannot force others to obey their commands like the Alpha can, unless the Alpha's command is to obey the Beta's command (then really the Alpha is just confirming that command). Other than a general desire among the group for a chain of command (which wasn't really needed until the pack grew to almost two dozen wolves) the commands of more "senior" wolves only carried weight equal to the "junior" wolf's respect for the senior.


Is any group of bits in a SHA-1 hash more/less unique than another?

Question: Is there any bias in certain parts of the hash? E.g., first n bits are more/less unique than the last/middle n bits? Is there any particular property of any group of bits that makes it more/less unique?
Comment: @mikeazo I guess that kind of remark could be an *important part of an answer*. But for anybody not directly into attacks on SHA - such as me - it certainly does not answer the question.
Comment: Possible duplicate http://crypto.stackexchange.com/questions/3153/sha-256-vs-any-256-bits-of-sha-512-which-is-more-secure
Comment: @mikeazo Eh, how do you recon that this is a dupe of that? Are you pointing to the right question?
Comment: @owlstead, okay maybe it would have been better to say related, but the answer to this follows directly from the other. If any set of bits is as secure as any other, then no group of bits is more/less unique.
Comment: Interesting question. I look at a lot of a breviated Git commit hashes (typically the first 8 hex digits of an sha1 digest), and they occasionally contain _no symbols other than [0-9]_ (that is, no [a-f]). By purely random chance, the odds of this are (10/16)^8, about 2.4%, but sometimes I have the impression that they're more common than this. Probably my perception is distorted.
Answer: Yes in a sense in terms of the Hamming weight/Hamming distance. This relates to how the changes of one bit or series of bits affect others. While there is also an avalanche effect counteracting many n string bits attacks, Hamming dictates some attacks to be more successful on certain n bit strings and thus certain n bit strings more vulnerable to exploits:
http://people.csail.mit.edu/yiqun/SHA1AttackProceedingVersion.pdf
http://www.sciencedirect.com/science/article/pii/S0166218X02005887
Comment: http://csrc.nist.gov/groups/ST/hash/documents/Rechberger_ImpactOfRotations.pdf


Windows Server, Apache HTTP Server and MySQL configuration odd?

Question: It is poor form to have Apache running on a windows server and connected to a MySQL database?  I've heard that MySQL is better in a linux environment.
Answer: I wouldn't say it is bad form at such, but using specifically Apache on windows is more prone to problems. Although in my experience I have found no real problems using windows, the only real downside is that the initial hardware requirements are greater since windows has a lot of rubbish running in the background.
MySQL runs just fine on windows and the management interface is very good.
Comment: I'm quite pleased with the interface, like you said.  I'd like to use linux but with everything else I need to learn, not sure if now is the right time to learn a completely new OS let alone a public facing site.  If it was on a LAN, that might be okay.  Plus the file names are case-sensitive on Linux (to my understanding) and we cannot be 100% confident that the developers kept the file names consistent in the link that reference those file names (I hope that makes sense to someone else who might be reading this).
Comment: Can you run MySQL Server 64-bit on an apache 32-bit web server?  I've only found un-signed 64bit apache installers.
Comment: MySQL doesn't run on Apache. They are separate programs. So you can use either. Yes file names are case sensitive on Linux so if you can't be sure that the files are linked properly then it might be better to use windows. Especially if that's what you are used to using.
Comment: What is your reasoning behind using Apache rather than IIS?
Comment: Familiarity, mainly.  There are some URL rewrite rules that are needed.  Can IIS do that?
Comment: Yes, IIS has lots of _plugins_ for example [URL-Rewrite](http://www.iis.net/downloads/microsoft/url-rewrite)


Will it be counted as a sin if it happened because of someone else?

Question: I wanted to know will a person commit any sin because of of someone else be counted as one? I actually got false information from someone about doing a particular act which was sin but he told it wasn't, so will that mean I also commited a sin or only that person?
Answer: Your sins are your own. You may be forgiven if you committed your sin in ignorance because Allah is Merciful, but that's not the same as not having committed the sin.
If someone else misguided you, their sins are their own; they may be carrying the sin of misguiding you as well as the burden of any additional sins you caused because of that misguidance, but again that's not the same as you not having committed the sin.
If you have sinned, and you know you have sinned, pray for repentance. Don't waste time trying to blame other people for it, Allah knows what you did and what they did and He is always the most Just of judges.
Comment: Brother/sister you answer less nowadays but when you do they are always on point Masha Allah.


Book on interpreting plots in regression analysis

Question: I am taking a regression course that is mainly theoretical. But we are given scatter plots and residual plots, and we are supposed to be able to describe the relationships and interpret them.  I find interpretation part difficult sometimes. Is there a good book that has exercises using SPSS output that I can use to help me interpret regression plots?
Answer: You could try:

Cook, R. D. (1999). Regression Graphics: Ideas for Studying Regressions through Graphics.

It isn't SPSS-based as far as I know (and for the record I haven't read it), but the substance of the plots that come with regression output should be sufficiently similar from software to software that it shouldn't matter.

You can also try reading through some of the threads on CV that are categorized under the tags regression and data-visualization (e.g., this search), or even under spss, residuals, or interpretation.
Finally, you should feel free to come back here with specific questions you have.  Just post a plot you are having trouble with and ask how to interpret it.  If CV won't let you post an image because your reputation is too low, you can upload it to imgur.com and include a link to it in your question.  Someone will add the figure for you.  If the plot is for a homework problem, you should add the [self-study] tag and explain what you have tried already, but you don't need to add the [self-study] tag otherwise.
Comment: Thanks a lot.In statistics I have a somewhat good theoretical knowledge.But when it comes to interpreting I always make mistakes
Comment: You're welcome, @clarkson. You should always feel free to come back w/ specific questions. There are a number of questions about interpreting plots already on CV; we can point you to those as well.
Comment: Alas, the book has no reference to SPSS nor any other software. It is also B&W.


Wireshark filter to display al packets which have traveled through switch

Question: I am trying to filter my packets based on whether or not they went through specific switch. This router has the ip address of 192.168.1.235. Is their a way to do this using Wireshark filters?
Comment: Switches are transparent devices, and they leave no mark on any frame that passes through them. The information necessary to do what you want does not exist.
Comment: @RonMaupin Oh well that sucks. Can switches produce their own packets?
Comment: What, exactly, are you trying to do?  There may be a simpler way to accomplish it.
Comment: A managed switch will have an address for management. The management interface looks like another host connected to the switch, but the management interface does not affect switching. Unmanaged switches will not have anything like that.
Comment: You can plug your monitoring device directly into the switch and configure a SPAN port to copy all frames on the switch to your monitoring device
Answer: Switches do not alter frames that run through them. Accordingly, there is no way to filter them by that.
Routers are directly addressed on the link layer, so you can filter for frames coming from or destined to a locally connected router by using a capture filter for its MAC address like ether host 00:11:22:33:44:55.
If you want to capture frames by switch, you need to set up port mirroring (SPAN or RSPAN on Cisco) and capture frames on the monitor port. If it's an unmanaged switch you'll need to temporarily connect a managed one. For 10/100 interfaces where throughput doesn't matter much, you could use a repeater hub and capture all frames off any of its ports.


What would be the reason for using asynchronous programming on a web server?

Question: I have a python/php background and just about to start work on a NodeJS project which is why I have this question. I have worked a bit on frontend JS but this is the first time I will be using JS for some backend work...I fully understand and appreciate the asynchronous nature of JS when it comes to frontend development. But I will be writing a bunch of APIs in NodeJS for the backend. Being new to NodeJS, I cannot help but think: What would be the reason to make asynchronous calls in my backend code? Are there specific scenarios where asynchronous calls will be better on the backend server? The API has to eventually return data in JSON format to the frontend caller....
Comment: Well, you can make two asynchronous calls at once. You can't make two synchronous calls at once.
Comment: I thought each HTTP request was served by a single thread in Node, since it ran on JavaScript, and JavaScript is single-threaded. I guess I'm curious about this question, too. Unless `await` works in Node similar to how `await` works in C#. Maybe it allows that thread to be suspended while it waits for some external resource, like access to a file system, database or web service?
Comment: yes nodejs is single threaded, but this single thread can switch between requests via an event loop while waiting on async io result
Comment: @hangyas node.js has only one thread. Yes, await works similarly in JS to how it works in c#.
Answer: Asynchronous calls are better when your application is io bound opposed to being cpu bound (in case of web applications, almost always). Talking to the database, receiving and sending packets on the network, reading files, etc. is slower than the CPU. Therefore while the program is waiting for the result of an async io call, it can work on processing other requests, resulting in better utilization of resources and responsivenes
It's also important to mention that OS threads are expensive so it's better if one thread can process multiple requests without being blocked. Imagine if fronted js would be synchronous and all tabs would run on their own OS threads: you could still use other tabs while js is blocking on one tab, but it would be a worse overall experience
Answer: The reason that you would use asynchronous programming on a webserver would be the same reason that it's standard / best practice to do so: to prevent your server from sitting idle and leaving other users waiting for Node to finish what it was doing.
Mainly you're going to want to make sure you're using asynchronous functions to read or write data from / to the file system or a database, as Node can use the time while it's waiting for the operation to complete to service other requests and perform other tasks, and only proceed with the asynchronous function once it has the result.
Basically, Node is designed to handle a lot of requests without a lot of threads, when used properly. It's probably worth having a closer look at the docs to get a better understanding of how it accomplishes this: https://nodejs.org/en/docs/guides/dont-block-the-event-loop
There's also a great article worth reading about measuring how many requests per second you can expect your Node instance to handle (with plenty of YMMV): https://plainenglish.io/blog/how-many-requests-can-handle-a-real-world-nodejs-server-side-application


How can you disable the Windows' "X" close button in the upper right-hand corner for a web-based program that is displayed in IE7?

Question: We are using a software program at our school to enter IEPs (Individualized Education Programs).  When entering goals and objectives for a student, users are provided with a Save and a Close button.  Close is meant for users not wishing to save the goal they just chose.  However, our users are sometimes wanting to back out of the screen and close the Window by clicking on the X in the upper right hand corner.  Unfortunately, this somehow corrupts data and the user has difficulty later entering goals.  The software company tells us to educate our staff not to click on the X and that there is no way to disable it.  The software is web-based and our school has standardized on IE7.
Answer: If it's web based, then you're probably just running a webpage in Internet Explorer. If that's the case, I'd recommend IE's kiosk mode.
If you need something a bit more heavyweight, Public Web Browser is a good and cheap choice that I've had good experiences with.
Answer: There is no way to disable the close button on the window (can you imagine!? ad popups that never go away! eek!).
However, you can catch it and do something useful (like click the "close" button on the form).  See:
http://blogs.x2line.com/al/archive/2004/09/15/561.aspx
Comment: This is what sites like Gmail or Stack Overflow do and it's a pretty sensible answer. Hitting "X" is not the only way to leave a site!
Answer: A lot of browsers have a full-screen mode (F11 in Firefox), where they take up the entire screen real estate, hiding any other UI elements, including the top bar (at least for Windows, dunno about *nix). This is a very simple solution, but afaik there's no way to disable the [x] for windows in general, you'd have to find a browser that does not use the default Windows look and doesn't implement it's own [x] in the corner.


iTunes suddenly will not let me add manually album art

Question: I am running High Sierra, updated, with iTunes 12.7.2.  My Music and Album Art is on an external HD.  I rip my own music into AIFF files, then manually add the album art.  This afternoon all of a sudden it will allow me to go through the motions, but the album art does not appear in iTunes.  I have checked the permissions for some of the files and they say I have read write permissions.  Please do not suggest downgrading my music.
Comment: Weird. What happens when you right click the album in iTunes, hit Album Info, and select Artwork?
Comment: Just like before when album art. . Standard operating procedure.  When I finalize the adding the album art. nothing happens for the last three I attempted   However today I added four new CDs and album art successfully was added.  I checked the permissions on folders and artwork and the music files.  I am logged in, I'm the administrator and I have read write privileges.
Comment: Also, I went back to these three today and tried again, no success.  Open up the art work and saved with a different file name. Still no success.
Answer: Sure, it's a year late, but I had this problem which lead me here, so someone else might, too. I had been adding cds to iTunes and manually adding covers, then one day it would not save the cover image. Here's what I did:
I turned off the Airplay on my iTunes.
This worked. I could save cover art again. Also changes I made to album info (fixing the album title, etc.) reverted back. Apparently, even though it showed these edits as changed, they were not saved when my speakers were set for airplay.
Comment: This was exactly the cause in my case. I'll add that "turning off AirPlay" simply involves only checking the "Computer" box. I guess this is a permissions issue while AirPlay is active, but a warning would have been nice. Filing a bug report with Apple...
Answer: I had the same problem with the iCloud Music Library when I manually uploaded some tracks to my library. I was able to edit all the properties, but not the artwork. When I added the artwork it never showed up in the end.
Later I have found out, how to solve this problem:

Remove the download of the song (you don't have to remove the song from the library, just the download via the context menu)
Upload the artwork again.
Before you save it, click on the artwork tab and select the image. It should then be bordered blue.
Now click save and the artwork should be saved now and also syncs to all the other devices.

I know that this question is a little bit older, but I hope to help other people with the same problem.


Is a 3 foot wide raised bed versatile enough?

Question: I have a small area of 15 feet by 10 feet and am thinking of doing three 3 foot by 8 foot beds with about 2 feet in between each.  But I could also do two large beds instead like two 5 foot by 8 foot beds.  Are there any advantages to either?  I just want to make sure that the space is usable.
Answer: Think about what you're going to plant and how much you want to plant. Come up with a list of everything you want to put in your garden and sketch it out roughly to scale to see if the design will work better for you. It's easier to make changes on paper before you build your beds.
A few years ago I read up on Square Foot Gardening by Mel Bartholomew but never implemented it. The book has consistently been one of the most popular books on gardening since it first came out and it's practiced by many home gardeners around the world. I reread the book and might build my raised beds this fall.
In the SFG System everything based is on a 1 square foot planting area. He recommends planting beds to be 4'x4' because you can easily reach into them and walk around them. 3'x3' is a good size for kids. Some people build longer beds but it's important to have one dimension not be bigger than 4' so that you can comfortably reach any plant. If the bed is only accessible from one side it shouldn't be more than 2' wide.
As for the length, having it too long means you have to walk a long way around to get to the other side. Aisles are a very important part of SFG and the new book emphasizes that. You need comfortable space to not only walk around but to work around. You'll be spending time kneeling and squatting and need space to do so without disturbing the plants. He recommends 3 feet for aisles but for years in the beginning he had his beds spaced 12" apart.
One of the reasons Bartholomew came up with the SFG system decades ago was because conventional row gardening was so wasteful. For example, seed packets have instructions like plant rows 3' apart and thin to 6". The row spacing is an artifact of production farming that uses heavy equipment. When working in raised beds you don't have to think about rows. If plants are thinned to 6" they only need 6" around them which means you can plant 4 in one square foot. Plants that are thinned to 4" can fit 9 in a square foot. Thinned to 3" you can fit 12 in a square foot.
Large plants take up the whole square foot. A few plants need more than 1 square foot.
Vining tomatoes fit in 1 sq ft provided it is trellised and side shoots are pruned weekly so only the main stem is left.
I would recommend the book even if you don't follow the whole square foot gardening system as you can still learn a lot from it for raised bed gardening in general.
Also... Don't limit yourself to having all your beds the same size and shape. Be creative and your vegetable garden can be a very attractive part of your landscape. Here's one example from http://blog.kittykono.com/2013/06/my-little-raised-bed-garden.html

I've always liked vegetable garden designs that become little outdoor rooms. Here's something I quickly threw together in a 15'x10' space. There's more square footage of beds than the 2 or 3 rows you had mentioned.
Answer: I think it depends what you're wanting to plant.  For instance a package of bush beans I happen to have next to me says "Plant in rows 24 inches apart".  So if you have 3 rows, 36 inches wide, I think you could get 3 rows of beans.  But if you had 2 rows 60 inches wide, I think you could get 4 rows of beans.
However, if you planted pole beans, the instructions say "Plant in rows 48 inches apart".  In that case, I don't see more than one row per bed.  So, you'd get more rows if the beds were 3 ft wide.
My tomato pack also says rows 48 inches apart.  Cucumbers says rows 60 inches apart.
Basil is 12 inches apart.  Corn rows are 24 inches.  Peppers rows are 24-36 inches.
Onions are 2-4 inches apart, so then it would be an area calculation. 2x5x8 = 80 compared to 3x3x8 = 72.  You have 8 more sq ft to plant onions if you had 5x8 beds.
If you're going to be planting tomatoes and cucumbers mostly, I'd go with the 3 rows 3x8. You'd also have more room to work between them.  You'd have room for a wheel barrow.
If you did three 3 ft beds, you could push the 2 outter rows all the way to the sides of the area and increase the path-width to 3 ft.  If you did two 5 ft beds, you will need a path on both sides of the bed, which reduces the path size to 5/3 = 1ft 8 in.  That's not very wide.
Comment: When you say for instance 24 inches apart.  Does that mean that the row also needs to be 24 inches away from the edge of the garden box?
Comment: @PapaBurgundy I think the row spacing is to allow plants to feed with their roots without much competition from other plants and allow the plant to expand to receive sunlight while not being too crowded (and shaded). In light of this, I think you could plant closer to the edge of the garden box since the garden box won't compete for nutrients nor compete for sunlight.
Answer: My 20'x20' garden is laid out like the 2nd diagram (domino-grid looking); I will be putting a keyhole garden in the center. I originally had rows, but I get lots more linear feet of growing space with this design. Is enclosed with 6' high trellis fence for vining plants; a gate at the center (as shown here) that opens to my chicken pen. When ready, I just let the chickens in and they keep it weeded for me. I also have a gate at top right corner (seldom use, but gives access w/o going thru chicken pen. Love it!
Comment: That sounds nice do you have a picture?
Answer: I just built 3 foot wide beds with a fence around the two beds. Since I can't reach it from both sides, 3 ft is almost too wide. Think about that stuff too!


What are most important recommendations for choosing clothing for my dog?

Question: What are most important recommendations for choosing clothing for my dog? What pets costumes store would you recommend?
Comment: It *really* feels like the question itself is just spambait, especially with the really close, and unimaginative user names.
Answer: In all honesty: don't put clothes on your dog.
If you simply have to, or you have a dog that likes wearing jackets or something, I'd suggest buying them at your local walmart/target or something along that lines.
But if it's a novelty costume, there are many trustworthy websites that you can find by simply looking up 'Dog T-Rex Costume' for example.
Answer: So, this can become a strong debate, and seems a little opinion based but I'll thrown in what "my answer" would be anyways. I had a pretty strong opinion for years that putting clothes on dogs is against nature, but so are A LOT of things that caring pet people do for their pets, so if it feels right to you, and doesn't harm your pet, go for it!
When I worked in a pet store, I heard some of the craziest reasons for wanting and needing pet clothing. Based on these stories, I'd put pet clothes into two categories necessity and accessory.
Necessary clothing would be:

Stress - "Thundershirts" and "Comfortcoats" are made to swaddle and fit tightly on pressure points to relieve separation and thunder anxiety.
Warmth - coats and sweaters that are purchased for hairless pets that get cold, sick pets with poor circulation or senior pets that also have issues keeping warm.
Potty problems - ponchos and raincoats, rainboots- although rare, I heard a story from a lady who has to put a raincoat on her dog because he refused to use the potty outside if he was getting wet. I hear A LOT that not all dogs will do their business when raining because they don't like their feet to get wet, but I've personally not experienced that as an issue.

Accessory clothing would be:

Dresses, pants, bows, hats, etc.

For putting clothes on your pet:

as a Fashion accessory or to match it's owners clothing;
for holiday events and parties;
or simply because you think it's cute!

I would just consider the thought "is this harmful?" Does is have drawstrings, buttons, tassles, bows etc that could be a choke hazard? Does the clothing cause my pup discomfort? Am I overheating my pet during warm weather? Can he or she still eliminate when wearing this, or will my pet hold it in? Does my pet have any sores, abscesses or rashes where the clothes could irritate it further?
Chances are if you're "pro-clothes" your opinion on the matter won't change because you read this, but maybe this will help someone!


How can I configure Unity's launcher auto-hide behavior?

Question: This has been an issue for me with Unity since its release.
I'd like to make the the launcher auto-hide. Especially on Netbooks, where screens are small, the launcher is quite wide, making it difficult to properly display some websites and other apps.
How can I configure the auto-hide behavior?
Answer: 11.04 & 11.10
The Unity launcher has an auto-hide option that is enabled by default. Lee's answer has the details. It has a few options:

Never - The launcher will never hide.
Autohide - The launcher will hide automatically based on time.
Dodge Windows - The launcher will hide when a window would overlay it.
Dodge Active Window - The launcher will hide only when an active window would overlay it.

This question has information on how to configure the different modes of Unity:

How can I configure Unity?
Comment: This doesn't seem to exist on 14.04.
Comment: @jzc This is the answer you want: http://askubuntu.com/a/106673/235
Comment: **I was looking for the additional options, Dodge Windows and Dodge Active Window.**

The answer you linked states: *Unlike previous versions of Ubuntu, the dodge windows option has been removed due to User testing that showed that this form of autohiding caused confusion.* (From the answer)
Answer: 12.04 and later - Unity
The Unity Launcher auto-hide option is now a System Setting - Appearance option:
By default, auto-hide is switched off - in previous versions of Ubuntu these behaviour was reverse.

From the Behaviour tab you have the option to switch-on autohiding of the Launcher and using the slide-bar to control the responsiveness to the reveal of the launcher.

You can use the Reveal Location radio-buttons to indicate where you need to position your mouse to reveal the launcher.
The option to switch on autohiding and controlling the hotspot location (left edge/top left corner) is on the Behaviour tab.
Unlike previous versions of Ubuntu, the dodge windows option has been removed due to User testing that showed that this form of autohiding caused confusion.
12.04 & Unity-2D
The Unity-2D Launcher delay is now a System Setting - Appearance option:

From the Behaviour tab you have the option to switch-on autohiding of the Launcher and by clicking the Low/High buttons to control the responsiveness to the reveal of the launcher.

You can use the Reveal Location radio-buttons to indicate where you need to position your mouse to reveal the launcher.
By default the auto-hide nature is toggled off meaning the launcher is permanently visible.

Linked Question:

Shortcut to change Launcher 'Hide' setting
Answer: 11.04 & 11.10
You can disable the autohide feature of the Unity launcher by following these simple steps:

WARNING: CCSM is an advanced tool and using it may break your Unity.
To avoid this, follow the steps exactly as mentioned here

Install the CompizConfig Settings Manager package via the Ubuntu Software Centre

Once installed, open the settings manager and scroll down until you see the 'Ubuntu Unity Plugin' which is located in the Desktop category.

Set 'Hide Launcher' to 'Never'.

The settings will have automatically applied and the launcher will now be locked in place.
Comment: The Compiz Config Settings Manager **[can break things](http://askubuntu.com/questions/80589/what-are-some-of-the-issues-with-ccsm-and-why-should-i-not-use-it)** See the [answer of jackocnr](http://askubuntu.com/a/43708/28323) to learn how to do this with standard gnome means.
Comment: This question was obviously answered before the launcher changes made in Unity.
Comment: dodge windows would be nice. I got back to Unity (Ubuntu 16.04) and i miss this option. I want autohide but not when I am on desktop.
Answer: If you don't have Compiz Config installed, you can still do this very easily.
 Launch gconf-editor by hitting Alt+F2 and then typing it and hitting Enter.
 Navigate to /apps/compiz-1/plugins/unityshell/screen0/options and then set launcher_hide_mode to 0.
Answer: With Compiz Config (ccsm) installed, go to the Ubuntu Unity Plugin, now you will see a drop-down menu next to the words Hide Launcher, click on the drop down menu and select Never and that is it, Unity launcher will no longer hide.

How can I configure Unity?
Comment: Oh, and on dual monitors, windows on the secondary screen maximise very strangely (full height, 20 px wide, on the edge)
Comment: Well, it always shows the launcher now, but windows get maximised behind it. Can that be fixed?
Comment: I've "fixed" both issues by picking the left monitor as the primary, instead of the right, which it apparently can't handle very well.
Comment: @Bart van Heukelom, how do you make a monitor primary?
Comment: @James McMahon With the Nvidia config tool
Comment: Is there no way to do it on an intel integrated card?
Comment: @scouser I've done that already, and checked with the gconf-editor, restarted the system but the launcher keeps on hiding. Ubuntu runs in a VM on my right side monitor, and the mouse crosses over to the host OS from the left edge. Everytime I move between OS's the launcher appears. I have tried changind the edge, but still of no avail
Comment: The Compiz Config Settings Manager **[can break things](http://askubuntu.com/questions/80589/what-are-some-of-the-issues-with-ccsm-and-why-should-i-not-use-it)** See the [answer of jackocnr](http://askubuntu.com/a/43708/28323) to learn how to do this with standard gnome means.
Answer: 16.04 CLI one liner
dconf write /org/compiz/profiles/unity/plugins/unityshell/launcher-hide-mode 1

0 is the default value for auto-hide off.
Found with:
dconf watch /

then changing it from GUI.
Answer: You can auto-hide the Unity Launcher. Follow the below steps to do so.

First open the System Setting.

Now Click on Appearance icon in Personal group.

Now a window similar to below one can be seen.

You can see that the auto-hide feature is turned OFF by default in my version(16.04).

You are there! Click on the toggle switch to turned the feature ON.

You can see that Unity-Launcher auto-hides when cursor is off from it.
You can do the same in Ubuntu versions above 12.04
Answer: You'd have to edit the source & rebuild unity.  Haven't checked this in some time, (natty), bit I believe it;s defined in unity/plugins/unityshell/src/LauncherHideMachine.cpp, possibly here (this is from unity-5.2 source
_hide_delay_timeout_length = 750;
Answer: 17.10
In Ubuntu 17.10, open Settings (can press windows/super key and search for settings) and then toggle the Auto-hide the Dock option under Dock.
Comment: Since upgrading to 18.10, the launcher no longer hides (not auto-hide) when the screen locks.


One site with two different domain name indexed in Google

Question: My site is indexed in google with too different domain names , one with http and another with https .
I was just wondering that if there is something I should do like trying omit one , or there is no problem and Google will take it .
Thanks.
Comment: We get this question a lot! You should only ever have one. You will likely want to redirect your HTTP site to HTTPS. Otherwise, if you do not redirect one to the other, you should use a canonical tag on your site to indicate only one is to be indexed. https://support.google.com/webmasters/answer/139066?hl=en This will avoid duplicate content issues and allow which ever site you chose to perform properly. Cheers!!
Answer: Since the web is moving to https, you ought to consider forcing all visitors to https.
You can do this by inserting the following code in your .htaccess file
<code>RewriteCond %{SERVER_PORT} =80
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</code>
However you need to check your site does not have 'mixed content' of http and https.  You will see a secure padlock if everything is OK.  If not, check the console in Developer Tools in your browser.


Simple examples of how a good notation or diagram can help to solve math problems

Question: I am looking for simple examples of situations where a good notation/diagram was fundamental for solving an elementary problem in mathematics (I am looking for examples accessible to a basic school student).
Comment: Which ages is basic school?
Answer: Two examples in probability:

A contingency table.
An events tree.
Comment: And good old Venn diagrams too :-)
Answer: "General interest" mathematics journals like Mathematics Magazine or The Mathematical Intelligencer sometimes have "proofs without words", and the Wikipedia article is also helpful. These are diagrams that more or less immediately prove a mathematical statement. For instance, there are a number of "rearrangement proofs" of the Pythagorean theorem. More examples are Cantone (2020) or Chakraborty (2018) or Mukherjee (2021), all of which are unfortunately paywalled. Roger Nelsen also published collections of such proofs in book form.
Comment: See also [Proofs without words on MathOverflow](https://mathoverflow.net/q/8846/102946).
Answer: Graph theory is my favorite example. Euler created it to solve the Konigsberg bridges problem. No algebra needed to play around with it.
Answer: Function Notation f(x)
Instead of:
$\forall x,y: [(x,y)\in f\implies x\in A \land y\in B]\\
\land ~ \forall x\in A: \exists y:[(x,y)\in f ~ \land ~ \forall z: [(x,z)\in f \implies z=y]]$
We can write:
$\forall x\in A: f(x)\in B$
Both fully and formally describe an arbitrary function mapping elements of a domain $A$ and to elements of a codomain $B$.
Comment: Those are not notations for the same thing. The first takes pains to require $f$ to be undefined on $x$ if $x\not\in A$, and it fails to use the notation $\exists!$ which, if used, would make notating the uniqueness condition easier. Still, it could be useful when the concept of "function" is being formally *defined*.

The second says nothing about $f(x)$ if $x\not\in A$, and it omits the uniqueness condition.
Comment: @RosieF (1) Neither of the above notations rules out $f$ being defined outside of $A$. They say only that $f$ is defined at least for those elements in the set $A$. (2) I think most students will find the $\exists!$ notation needlessly difficult to work with. (3) $f(x)=f(x)$ for $x\in A$. If $a, ~b\in A$ and $a=b$, then $f(a)=f(b)$, hence the uniqueness requirement is actually built into the notation.
Answer: I think tables are a very powerful method for making sense of logic problems.  Before, I knew the method, found these GRE/LSAT* problems much harder.  I think the benefit is in (1) overcoming the working memory bottleneck and (2) making sure all cases are covered.
For example:  https://www.youtube.com/watch?v=loyetRWK3VU
P.s.  Tables are not the only form of diagram for logic problems, but are pretty common.  Sometimes just linking networks are the diagrams.  If you check out an LSAT prep book, they will show several types of diagrams.
*It looks like the GRE Analytical section has been changed into a writing sample.  Used to consist of LSAT style questions.  (Not sure if the writing sample benefits from tables/not.)


Where do we put the "html.parser" argument when web scraping?

Question: Look at the following snippet of code
<code>import requests
from bs4 import BeautifulSoup
url = #Insert url here

# Method 1
html = requests.get(url, "html.parser")
soup = BeautifulSoup( html.text )

#Method 2
html2 = requests.get(url)
soup2 = BeautifulSoup( html.text, "html.parser")
</code>
Which method is correct ? Method 1 or Method 2 ? Should we put "html.parser" in requests.get() or BeautifulSoup() ?
Answer: Parsers are not a part of HTTP request.
It's a method to parse different types of document. So, during parsing the html document using BeautifulSoup you have to mention the parser
So, method 2 is correct.
DocString of BeautifulSoup constructor

:param markup: A string or a file-like object representing
markup to be parsed.

:param features: Desirable features of the parser to be used. This
may be the name of a specific parser ("lxml", "lxml-xml",
"html.parser", or "html5lib") or it may be the type of markup
to be used ("html", "html5", "xml"). It's recommended that you
name a specific parser, so that Beautiful Soup gives you the
same results across platforms and virtual environments.
Answer: If I understand correctly, your method 2 is correct and you would want to put it on the BeautifulSoup constructor because

Requests is separate from Beautiful Soup and I don't believe putting the "html.parser" on the constructor will do anything
You want to specify the parser for Beautiful Soup because it could be parsing things other than html e.g lxml's XML parser

Beautiful Soup Docs


Accidentally deleted icons in /usr/share, how do I get them back?

Question: okay, so tyeing to type "icons" in the /usr/share/ directory, hit the delete key as root, now my icons are gone, all of them, the options for play in totem or the ones on the desktop....all of them, any help?
Answer: I like Bash porn so I wrote you a present:
for p in `dpkg -l | awk '/^ii  [^\ ]+/ {print $2}'`; do
    if [[ $(dpkg -L $p | grep /usr/share/icons/) ]]; then
        echo $p;
    fi;
done

That echos out all the installed packages that had files in /usr/share/icons/. If that works for you (it does for me) you can replace the echo statement with:
        sudo apt-get --reinstall install $p

It's going to use a lot of bandwidth and whatever you do, don't interrupt it, but it should get you all your packaged icons back.
Of course you can reverse that logic so you use something like this:
sudo apt-get --reinstall -s install $(for p in `dpkg -l | awk '/^ii  [^\ ]+/ {print $2}'`; do if [[ $(dpkg -L $p | grep /usr/share/icons/) ]]; then echo $p; fi; done)

The -s in there means simulation mode. That command won't actually do anything unless you remove the -s, it'll just show you what it would do. I'd probably recommend that before you jump in.

As Andrea points out dpkg -S can do all this on its own. Plus it's much quicker.
sudo apt-get -s --reinstall  install `dpkg -S /usr/share/icons/ | sed 's/,//g; s/\:.*$//'`

Comment: Wow. Lots of awesome stuff in there.. I'll be studying that script carefully!
Comment: You can use `dpkg -S /usr/share/icons/` instead of the for loop ;-)
Comment: @Oli Very nice(/clever/inteligent) loop. well done.
Comment: I did the same thing and solved it using Andrea's solution and it worked fantastically as well as quickly. Thank you so much!!!
Answer: You will need to do something like:
sudo apt-get install --reinstall $package

You will need to replace $package with a list of package names, for every single package which had files under that path. That is quite a lot of packages, especially if you have any non-default packages installed.
Something like this might be a good start for you:
sudo apt-get install --reinstall aisleriot alacarte apport aptdaemon-data brasero-common \
bzr-gtk cabextract checkbox dmz-cursor-theme eog evince-common evolution-common \
file-roller gnome-accessibility-themes gnome-applets-data gnome-bluetooth \
gnome-control-center-data gnome-disk-utility gnome-icon-theme \
gnome-icon-theme-symbolic gnome-keyring gnome-mahjongg gnome-media gnome-nettool \
gnome-online-accounts gnome-panel-data gnome-power-manager gnome-session-common \
gnome-settings-daemon gnome-system-log gnome-system-tools gnome-themes-standard \
gwibber hicolor-icon-theme human-icon-theme human-theme humanity-icon-theme ibus \
jockey-common libgweather-common liblaunchpad-integration-common libpeas-common \
libreoffice-common nautilus-data network-manager-gnome onboard openjdk-7-jre \
rhythmbox-data seahorse software-center software-properties-gtk synaptic \
totem-common transmission-common ubuntu-artwork ubuntu-mono ubuntuone-client \
ubuntuone-installer unity-asset-pool update-manager update-notifier usb-creator-gtk \
xcursor-themes

Answer: oh :))
first of all :: don't do this again :)
now, depending on which icons you had, you should reinstall them back via synaptic, console, or USC (ubuntu software center), as was mentioned by 2 other answers
if icons were from default themes, them simply reinstall this
gnome-icon-theme
ex. command from dobey will look like this
apt-get install --reinstall gnome-icon-theme


Is a Cm7 chord considered minor or dominant?

Question: Is a Cm7 chord considered minor or dominant? I'm studying jazz and trying to identify chord scales for particular harmonies. Also, what modes qualify to possibly fit with a Cm7 chord and how do I determine which they are?
Answer: It's definitely not dominant because you don't have a diminished triad between the 3rd, 5th, and 7th so it can't function as dominant. If you break it up, you actually get a minor triad between the root, 3rd, and 5th and a major triad between the 3rd, 5th, and 7th.
It is just a minor 7th found in a few different scales/modes pretty much any natural mode that is minor. A basic dominant chord chord would typically contain a root, major third, perfect fifth, and minor seven as shown here.
Answer: The question whether Cm7 can be considered a dominant chord has already been answered (the answer is: no). But now for the chord scales. Any scale containing a Cm7 chord can function as a chord scale for Cm7:

C dorian: C D Eb F G A Bb
C aeolian:  C D Eb F G Ab Bb
C phrygian:  C Db Eb F G Ab Bb

The difference is the number of avoid notes that these scales have (with respect to the Cm7 chord). Dorian has none, aeolian has one (the sixth scale degree Ab), and phrygian has two avoid notes (the second and the sixth degrees, Db and Ab). Avoid notes are, loosely speaking, scale notes that are a semitone higher than a chord tone. The fact that the dorian scale has no avoid notes when used over a minor seventh chord makes it the most used chord scale for such a chord.
For more information about avoid notes take a look at this blog post.
Answer: If you limit the case in a modern jazz world, I believe you can consider "loosely dominant" a minor seventh chord if you establish its "tonic" a fifth below.
For example in a dorian mode. This one is the first proper mode for a minor seventh chord.
Comment: The concept of "dominant" in music (since Gregorian chant era, at least) is not exclusively matter of the fifth degree of the scale (especially in a modal context). It's matter of how much some degrees (may be more than one, let us say one or two) other than the first (or finalis) insist on a certain note before find relax on another degree (mostly the first one). So, as you can find i.e. in many Ravel's cadences, you can have a minor seventh chord on the fifth degree resolving on the first. In jazz music now is not problematic at all to use that chord as a dominant. Specially in modal jazz.
Comment: Does that mean we could use Cm7 as a "surrogate dominant"(if that term was to exist), if it proceeds to F or F (i.e, in the ii-V-I progression)?
Answer: There's THE dominant of a key, which is the fifth note of the home scale, or the chord built on it.   Or there's a more loosely-defined dominant function which can consider Am7, Dm7, G7, C as a string of "secondary dominants".  You can spice this up by making the secondary dominant chords major - A7, D7, G7, C is quite normal and acceptable, and if your theory book can't cope with it without inventing temporary modulations or "borrowing" chords, get a better theory book!
Much jazz is based on jumping to a remote chord and finding the way home through a string of secondary dominants, or their b5 substitutions. Even "Giant Steps" is largely a series of ii7, V7, I fragments.  This "string of dominants" is such a strong progression!


Does Nucleation Occur during Phase Equilibrium?

Question: I understand that during phase transition nucleation must occur. I'm wondering, once phase equilibrium is established, does nucleation still occur? For instance, in liquid-vapour equilibrium, does independent water molecules just simply enter and leave the liquid-vapour interface, or does some kind of nucleation (say liquid to vapour) have to happen during equilibrium phase transition?
Answer: There are actually two questions here. At phase equilibrium, yes independent water molecules do enter and leave the liquid vapour interface. The rate of crossing of individual molecules from one phase to another is characterized by an Arrhenius type rate equation of the form: $$\alpha \exp \left[ - \frac{\Delta E}{kT} \right]$$ where $\Delta E$ is the activation energy and $\alpha$ is the so called rate constant. There is a separate rate equation for liquid-vapour and for vapour to liquid. The difference between the liquid-to-vapour and vapour-to-liquid activation energies is the latent heat per molecule. The rate constant is dependent on a large number of factors and usually has to be experimentally determined. The two exponentials cross at the equilibrium temperature so that at this point the rates of transfer in each direction are equal. Below this temperature the vapour-to-liquid rate is higher, above the liquid-to-vapour rate is higher.
However this rate behaviour is for transfer of molecules across existing phase interfaces and so has nothing to do with nucleation which concerns the formation of new interfaces. Nucleation requires the formation of sizable clusters of molecules in one phase or the other. This formation is a random process. Exactly how big a cluster has to be to be regarded as a true region of the phase depends a lot on the specific system and state. However at any temperature there is a certain critical size above which the cluster is stable. Although transient cluster formation still occurs at all temperatures, at equilibrium the rate of growth of any phase is effectively zero and so the formation of new phase regions above the critical size is highly unlikely.
Comment: Under what conditions do we have independent transfer of molecules or nucleation? In boiling, we see nucleation but if I leave a cup of water on a table we don't. Similarly in winter liquid nucleate on car winters/in our breathing. Is nucleation only an effect seen when the current state is not stable (during heating/cooling) or metastable (supercool/heated liquid) and not during phase equilibrium?


Essential Nodes in a Circuit

Question:
My book says above that there are three essential nodes in the circuit above. I am seeing four essential nodes in total which are marked by those four black dots. Since each of those black dots connect three or more circuit elements? Can someone explain to me how there are 3 essential nodes instead of 4 essential nodes?
Answer: The bottom two Nodes are effectively at the same potential. So they can be considered as a single Node.
Regards
Answer: Black dots do NOT indicate nodes. They are visual markers.
A node is the complete interconnection between circuit elements. There are four nodes in your circuit.
An essential node a node where three or more elements meet.
There are three essential nodes in your circuit. The bottom-most node in your circuit is one of three essential nodes.

Essential Nodes in a Circuit


Does Density Functional Theory (DFT) underestimate the conduction band level only?

Question: Based on the detailed answers provided for the reasons for the underestimation of bandgaps in DFT calculations, can we deduce that it is based on an underestimation of the conduction band level but not the valence band level?
Answer: No. Considering a DFT calculation of a molecule, the HOMO level could be in principle related to ionization energy, but is not equal to it. The problem goes beyond just a misplacement of the LUMO level.
You can do the analogy from a finite system, such as an atom or molecule, to a periodic system with electronic bands (HOMO -> valence band maximum and LUMO -> conduction band minimum).


Get legend as a separate picture in Matplotlib

Question: I'm developing a Web application and want to display a figure and its legend in different locations on the page. Which means I need to save the legend as a separate png file. Is this possible in Matplotlib in a more or less straightforward way?
Answer: This could work:
import pylab
fig = pylab.figure()
figlegend = pylab.figure(figsize=(3,2))
ax = fig.add_subplot(111)
lines = ax.plot(range(10), pylab.randn(10), range(10), pylab.randn(10))
figlegend.legend(lines, ('one', 'two'), 'center')
fig.show()
figlegend.show()
figlegend.savefig('legend.png')

Comment: Nice, alternatively use `figlegend.legend(ax.get_legend_handles_labels()[0], ax[get_legend_handles_labels()[1])` e.g. if multiple plots are added to `ax` in a for-loop.
Answer: You may limit the saved region of a figure to the bounding box of the legend using the bbox_inches argument to fig.savefig. Below to versions of a function which you can simply call with the legend you want to save as argument. You may either use the legend created in the original figure here (and remove it afterwards, legend.remove()) or you may create a new figure for the legend and simply use the function as it is.
Export legend boundingbox
In case the complete legend shall be saved, the bounding box supplied to the bbox_inches argument would be simply the transformed bounding box of the legend. This works well if the legend has no border around it.
import matplotlib.pyplot as plt

colors = ["crimson", "purple", "gold"]
f = lambda m,c: plt.plot([],[],marker=m, color=c, ls="none")[0]
handles = [f("s", colors[i]) for i in range(3)]
labels = colors
legend = plt.legend(handles, labels, loc=3, framealpha=1, frameon=False)

def export_legend(legend, filename="legend.png"):
    fig  = legend.figure
    fig.canvas.draw()
    bbox  = legend.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
    fig.savefig(filename, dpi="figure", bbox_inches=bbox)

export_legend(legend)
plt.show()

Export extended legend bounding box
If there is a border around the legend, the above solution may be suboptimal. In this case it makes sense to extend the bounding box by some pixels to include the border to its full.
import numpy as np
import matplotlib.pyplot as plt

colors = ["crimson", "purple", "gold"]
f = lambda m,c: plt.plot([],[],marker=m, color=c, ls="none")[0]
handles = [f("s", colors[i]) for i in range(3)]
labels = colors
legend = plt.legend(handles, labels, loc=3, framealpha=1, frameon=True)

def export_legend(legend, filename="legend.png", expand=[-5,-5,5,5]):
    fig  = legend.figure
    fig.canvas.draw()
    bbox  = legend.get_window_extent()
    bbox = bbox.from_extents(*(bbox.extents + np.array(expand)))
    bbox = bbox.transformed(fig.dpi_scale_trans.inverted())
    fig.savefig(filename, dpi="figure", bbox_inches=bbox)

export_legend(legend)
plt.show()

Comment: This is a great answer which gave me exactly what I wanted. I would only add `legend.axes.axis("off")` to the `export_legend()` function so that the frame of the phantom axes doesn't show up on larger legends.
Comment: This approach has a downside: since this only changes the bounding boxes, the resulting image file can be of a very **large file size as same as the original plot**, when saved as PDF or vector graphics. If your original plot had many points and were 10MB, for instance, the file for legend only would be also 10MB.
Answer: use pylab.figlegend(..) and get_legend_handles_labels(..):
import pylab, numpy
x = numpy.arange(10)

# create a figure for the data
figData = pylab.figure()
ax = pylab.gca()

for i in xrange(3):
    pylab.plot(x, x * (i+1), label='line %d' % i)

# create a second figure for the legend
figLegend = pylab.figure(figsize = (1.5,1.3))

# produce a legend for the objects in the other figure
pylab.figlegend(*ax.get_legend_handles_labels(), loc = 'upper left')

# save the two figures to files
figData.savefig("plot.png")
figLegend.savefig("legend.png")

It can be tricky though to get the size of the legend figure right in an automated manner.
Comment: There should be figData.save... instead of figPlot.save... Nice example.
Answer: It is possible to use axes.get_legend_handles_labels to get the legend handles and labels from one axes object and to use them to add them to an axes in a different figure.
# create a figure with one subplot
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1,2,3,4,5], [1,2,3,4,5], 'r', label='test')
# save it *without* adding a legend
fig.savefig('image.png')

# then create a new image
# adjust the figure size as necessary
figsize = (3, 3)
fig_leg = plt.figure(figsize=figsize)
ax_leg = fig_leg.add_subplot(111)
# add the legend from the previous axes
ax_leg.legend(*ax.get_legend_handles_labels(), loc='center')
# hide the axes frame and the x/y labels
ax_leg.axis('off')
fig_leg.savefig('legend.png')

If for some reason you want to hide only the axes label, you can use:
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)

or if, for some weirder reason, you want to hide the axes frame but not the axes labels you can use:
ax.set_frame_on(False)

ps: this answer has been adapted from my answer to a duplicate question
Comment: This method fails for `ax.fill_between`.
For example, if I insert the line `ax.fill_between([1,2,3,4,5], [2,3,4,5,6], y2=[1,2,3,4,5], label='test2')` before the first `fig.save` call, then `ax_leg.legend` throws the following error:
`RuntimeError: Can not put single artist in more than one figure`

Can You think of a solution for this case?
Comment: I think that this would make a good question. If you elaborate the question you will for sure get some answer. I don't know why it fails
Answer: I've found that the easiest way is just to create your legend and then just turn off the axis with plt.gca().set_axis_off():
# Create a color palette
palette = dict(zip(['one', 'two'], ['b', 'g']))
# Create legend handles manually
handles = [mpl.patches.Patch(color=palette[x], label=x) for x in palette.keys()]
# Create legend
plt.legend(handles=handles)
# Get current axes object and turn off axis
plt.gca().set_axis_off()
plt.show()

Comment: There is a huge white space to the left of the legend in this approach.
Answer: This calculates the size of the legend automatically. If mode == 1, the code is similar to Steve Tjoa's answer, while mode == 2 is similar Andre Holzner's answer.
The loc parameter must be set to 'center' to make it work (but I do not know why this is necessary).
mode = 1
#mode = 2

import pylab
fig = pylab.figure()
if mode == 1:
    lines = fig.gca().plot(range(10), pylab.randn(10), range(10), pylab.randn(10))
    legend_fig = pylab.figure(figsize=(3,2))
    legend = legend_fig.legend(lines, ('one', 'two'), 'center')
if mode == 2:
    fig.gca().plot(range(10), pylab.randn(10), range(10), pylab.randn(10), label='asd')
    legend_fig = pylab.figure()
    legend = pylab.figlegend(*fig.gca().get_legend_handles_labels(), loc = 'center')
legend.get_frame().set_color('0.70')
legend_fig.canvas.draw()
legend_fig.savefig('legend_cropped.png',
    bbox_inches=legend.get_window_extent().transformed(legend_fig.dpi_scale_trans.inverted()))
legend_fig.savefig('legend_original.png')

Original (uncropped) legend:

Cropped legend:
Comment: This is great, but seems to cut the top of the legend text for me.
Comment: @joeln, you're right, this does clip a little too much. You can get around this by getting the clipped bounding box, and expanding it by a factor (in this case, 1.1 times biger in width and height):  `bbox = legend.get_window_extent().transformed(legend_fig.dpi_scale_trans.inverted()); ll, ur = bbox.get_points(); x0, y0 = ll; x1, y1 = ur; w, h = x1 - x0, y1 - y0; x1, y1 = x0 + w * 1.1, y0 + h * 1.1; bbox = matplotlib.transforms.Bbox(np.array(((x0, y0),(x1, y1)))); legend_fig.savefig('filename', bbox_inches=bbox)`
Comment: @joeln, are you able to reproduce the figures that are included in the answer? They look correct.
Comment: @RichardLaw, I tried your approach but the left border of the legend frame is still clipped. Had to expand the lower left corner as well (x0 = x1 - w*1.1, y0 = y1 - h*1.1, where x1 and y1 are those before expansion) to get it to work. It would be good if your solution is included in the answer as well.
Answer: Inspired by Maxim and ImportanceOfBeingErnest's answers,
def export_legend(ax, filename="legend.pdf"):
    fig2 = plt.figure()
    ax2 = fig2.add_subplot()
    ax2.axis('off')
    legend = ax2.legend(*ax.get_legend_handles_labels(), frameon=False, loc='lower center', ncol=10,)
    fig  = legend.figure
    fig.canvas.draw()
    bbox  = legend.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
    fig.savefig(filename, dpi="figure", bbox_inches=bbox)

which allows me to save legend horizontally in a separate file. As an example
Answer: In November 2020, I tried almost everything on this post, but none worked for me. After struggling for a while, I found a solution that does what I want.
Pretend you want to draw a figure and a legend separately that looks like below (apparently I don't have enough reputation to embed pictures in a post; click the links to see the picture).
import matplotlib.pyplot as plt
%matplotlib inline

fig, ax = plt.subplots()

ax.plot([1, 2, 3], label="test1")
ax.plot([3, 2, 1], label="test2")

ax.legend()

 target figure
You can separate the figure and the legend in two different ax objects:
fig, [ax1, ax2] = plt.subplots(1, 2)

ax1.plot([1, 2, 3], label="test1")
ax1.plot([3, 2, 1], label="test2")

ax2.plot([1, 2, 3], label="test1")
ax2.plot([3, 2, 1], label="test2")
h, l = ax2.get_legend_handles_labels()
ax2.clear()
ax2.legend(h, l, loc='upper left')
ax2.axis('off')

 fixed figure 1
You can easily control where the legend should go:
fig, [ax1, ax2] = plt.subplots(2, 1)

ax1.plot([1, 2, 3], label="test1")
ax1.plot([3, 2, 1], label="test2")

ax2.plot([1, 2, 3], label="test1")
ax2.plot([3, 2, 1], label="test2")
h, l = ax2.get_legend_handles_labels()
ax2.clear()
ax2.legend(h, l, loc='upper left')
ax2.axis('off')

 fixed figure 2
Answer: I'd like to add a small contribution for the specific case where your legend is customized such as here: https://matplotlib.org/3.1.1/gallery/text_labels_and_annotations/custom_legends.html
In that case, you might have to go for a different method. I've been exposed to that problem and the answers above did not work for me.
The code below sets-up the legend.
    import cmocean
    import matplotlib
    from matplotlib.lines import Line2D

    lightcmap = cmocean.tools.lighten(cmo.solar, 0.7)
    custom_legend = []
    custom_legend_strings=['no impact - high confidence', 'no impact - low confidence', 'impact - low confidence', 'impact - high confidence']

    for nbre_classes in range(len(custom_legend_strings)):
        custom_legend.append(Line2D([0], [0], color=lightcmap(nbre_classes/len(custom_legend_strings)), lw=4))

I think because this kind of legend is attached the axes, a little trick was necessary :
center the legend with a big font to make it take most of the available space and do not erase but set the axes to off :
    fig,ax = plt.subplots(figsize=(10,10))
    ax.legend(custom_legend,custom_legend_strings, loc = 10, fontsize=30)
    plt.axis('off')
    fig.savefig('legend.png', bbox_inches='tight')

The result is :
the result
Answer: I was not able to find exactly what I wanted in the existing answer so I implemented it. It wanted to generate a standalone legend without any figure attached nor visual "glitches". I came up with this:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.patches import Patch

palette = dict(zip(['one', 'two', 'tree', 'four'], ['b', 'g', 'r', 'k']))

def export_legend(palette, dpi="figure", filename="legend.png"):
    # Create empty figure with the legend
    handles = [Patch(color=c, label=l) for l, c in palette.items()]
    fig = plt.figure()
    legend = fig.gca().legend(handles=handles, framealpha=1, frameon=True)

    # Render the legend
    fig.canvas.draw()

    # Export the figure, limiting the bounding box to the legend area,
    # slighly extended to ensure the surrounding rounded corner box of
    # is not cropped. Transparency is enabled, so it is not an issue.
    bbox  = legend.get_window_extent().padded(2)
    bbox = bbox.transformed(fig.dpi_scale_trans.inverted())
    fig.savefig(filename, dpi=dpi, transparent=True, bbox_inches=bbox)

    # Delete the legend along with its temporary figure
    plt.close(fig)

export_legend(palette, dpi=400)

Note that the surrounding background is transparent, so adding the legend on top of a figure should not have white "glitches" in the corners, nor issue of cropped border.
And if you don't want to save the image of disk, here is the trick !
DPI = 400

def export_legend(palette):
    # Create empty figure with the legend
    handles = [Patch(color=c, label=l) for l, c in palette.items()]
    fig = plt.figure()
    legend = fig.gca().legend(handles=handles, framealpha=1, frameon=True)

    # Render the legend
    fig.canvas.draw()

    # Export the figure, limiting the bounding box to the legend area,
    # slighly extended to ensure the surrounding rounded corner box of
    # is not cropped. Transparency is enabled, so it is not an issue.
    bbox = legend.get_window_extent().padded(2)
    bbox_inches = bbox.transformed(fig.dpi_scale_trans.inverted())
    bbox_inches = bbox.from_extents(np.round(bbox_inches.extents * 400) / 400)
    io_buf = io.BytesIO()
    fig.savefig(io_buf, format='rgba', dpi=DPI, transparent=True, bbox_inches=bbox_inches)
    io_buf.seek(0)
    img_raw = io_buf.getvalue()
    img_size = (np.asarray(bbox_inches.bounds)[2:] * DPI).astype(int)

    # Delete the legend along with its temporary figure
    plt.close(fig)

    return img_raw, img_size

The raw buffer can be read directly using PIL or whatever dealing with raw buffer.
Answer: So I was playing with this idea and simplest thing I have found is this (works with multiple axes):
def export_legend(filename="legend.png", fig=fig):
        legend = fig.legend(framealpha=1)

        fig2  = legend.figure
        fig2.canvas.draw()
        bbox  = legend.get_window_extent().transformed(fig2.dpi_scale_trans.inverted())
        fig2.savefig(filename, dpi="figure", bbox_inches=bbox, facecolor="w")
        legend.remove() # removes legend from showing on plot

    export_legend()

Output of a function (I hided labels with boxes):

fig is from fig, ax = plt.subplots()
If you want legend to still show on plot you can use (for example):
fig.legend(loc="upper right", bbox_to_anchor=(1, 1), bbox_transform=ax.transAxes)


Does hunx have an origin?

Question: I was reading Anthony Trollope's The Way We Live Now.  A character calls an old man, "an old hunx" during an argument.  I was wondering if Trollope was writing in an accent or if hunx was an old slang word.  I tried Googling it, but only found websites relating to "Hunx and His Punx." The reference can be viewed here on Project Gutenberg.
Comment: *Slang* is not a count noun.  You simply cannot **an old slang*.  It makes no sense. It is not English.
Comment: Fixed to make it "old slang *word*", and added link to the text (which is a 2MB HTML file, btw). It's a legit question, and "hunx" is a rather bizarre word that I'd be curious about origins and meaning.
Answer: Here's the entry from OED 1:

Ashley Thorndike (Shakespeare's Theatre, 1916, 33) states that one of the favorite performers at the Bear Garden in Shakespeare's day was a blind bear named Old Hunks; he does not give a source, but the pre-Civil War quotations suggest allusions to the poor beast.
Comment: Aaah, can't beat OED!
Answer: There is a reference to the word in Folk-Etymology: A Dictionary of Verbal Corruptions Or Words Perverted in Form Or Meaning, by False Derivation Or Mistaken Analogy, an 1882 book by Reverend A. Smythe Palmer.

And in Specimens of English Dialect (Skeat & Elworthy, 1900):

Does hunx have an origin?


Particle-hole symmetry in 2nd quantization

Question: In second quantization one the Particle-hole transformation is defined as
\begin{align}
\hat{\mathcal{C}} \hat{\psi}_A \hat{\mathcal{C}}^{-1} &= \sum_B U^{*\dagger}_{A,B} \hat{\psi}^{\dagger}_B \\
\hat{\mathcal{C}} \hat{\psi}_A^{\dagger} \hat{\mathcal{C}}^{-1} &= \sum_B \hat{\psi}_B U^{*}_{B,A} \\
\hat{\mathcal{C}} i \hat{\mathcal{C}}^{-1} &= +i
\end{align}
And if in a 2nd quantized Fermionic Hamiltonian ($\hat{\mathcal{H}} $) Particle Hole symmetry is present then
$$
\hat{\mathcal{C}} \hat{\mathcal{H}} \hat{\mathcal{C}}^{-1} = \hat{\mathcal{H}}
$$
I want to see what this equation means in single particle basis. In single particle basis I can write the 2nd quantized Hamiltonian ($\hat{\mathcal{H}}$) as
$$
\hat{\mathcal{H}}=\sum_{A,B}\hat{\psi}^\dagger_{A}H_{A,B}\hat{\psi}_B
$$
Here the matrix $H$ is the Hamiltonian in single particle basis.
Now, with the transformation rules on should get
$$
U H^{*} U^{\dagger} = - H
$$
In the single-particle basis. But what I am getting using the transformation rules is
$$
U^* H U^{*\dagger} = -H
$$
Now I have started to think whether the transformation rules given here are right or not. I wanted to know if the transformation rule or my calculation is wrong.
Source: Topological phases: Classification of topological insulators and superconductors of non-interacting fermions, and beyond Equation 17
Answer: The transformation rules given are correct. We have
\begin{align}
\hat{\mathcal{C}} \hat{\mathcal{H}} \hat{\mathcal{C}}^{-1} & =
\sum_{AB} \hat{\mathcal{C}} \hat{\psi}^{\dagger}_A \hat{\mathcal{C}}^{-1} \hat{\mathcal{C}} H_{AB} \hat{\mathcal{C}}^{-1} \hat{\mathcal{C}} \hat{\psi}_B \hat{\mathcal{C}}^{-1}
 = \sum_{AB} \, (\sum_{C}\hat{\psi}_C U^{*}_{CA}) \, H_{AB} \, (\sum_{D}U^{*\dagger}_{BD}\hat{\psi}^{\dagger}_D) \nonumber\\
& = \sum_{ABCD} \hat{\psi}_C \, U^{*}_{CA} \, H_{AB} \, U^{*\dagger}_{BD} \, \hat{\psi}^{\dagger}_D
= \sum_{CD} \hat{\psi}_C \, (U^* H U^{*\dagger})_{CD} \, \hat{\psi}^{\dagger}_D \nonumber\\
& = -\sum_{CD} \hat{\psi}^{\dagger}_D \, (U^* H U^{*\dagger})_{CD} \, \hat{\psi}_C
= -\sum_{CD} \hat{\psi}^{\dagger}_D \, (U^* H U^{*\dagger})^T_{DC} \, \hat{\psi}_C
= -\hat{\psi}^{\dagger} (U^* H U^{*\dagger})^T \hat{\psi} \nonumber\\
& = -\hat{\psi}^{\dagger} (U H^T U^{\dagger}) \hat{\psi}
= -\hat{\psi}^{\dagger} (U H^* U^{\dagger}) \hat{\psi} \,,
\end{align}
where in the 1st line 2nd equality, I've used your transformation rules. Note that everything is in component form, so $H_{AB}$ is just a complex number, and with $\hat{\mathcal{C}} i \hat{\mathcal{C}}^{-1} =  i$, we have $\hat{\mathcal{C}} H_{AB} \hat{\mathcal{C}}^{-1} = H_{AB}$. In the 3rd line 1st equality I have used the fermion anticommutation rules. In the same line last equality I have written everything from component form into matrix multiplication form. In the last line last equality I have used the Hermiticity of $H$.
Now suppose there is particle-hole symmetry so we also have the above equals $\hat{\mathcal{H}} = \hat{\psi}^{\dagger} H \hat{\psi}$, so we need to have
\begin{equation}
U H^* U^{\dagger} = -H.
\end{equation}
Answer: This is a good question that I have also had, so I'm answering this even though it is two years old! It looks like your definitions are all fine, but I would use
\begin{equation}
    \hat{\mathcal{P}}\hat{\psi}^{}_{A}\hat{\mathcal{P}}^{-1} = \sum_{B} \hat{\psi}_{B}^{\dagger}(U_{P})_{B, A}
\end{equation}
as it simplifies notation. I'll also refer to the particle-hole operator as $\hat{\mathcal{P}}$ to keep my notation clear, but that's just a personal preference.
Using the above definition we implement the transformation of $\hat{\mathcal{P}}$ on $\hat{H}$ as
\begin{equation}
    \begin{split}
        \hat{\mathcal{P}}\hat{H}\hat{\mathcal{P}}^{-1} &= \sum_{A, B} \hat{\mathcal{P}} \hat{\psi}_{A}^{\dagger} \hat{\mathcal{P}}^{-1} \hat{\mathcal{P}} H^{}_{A, B} \hat{\mathcal{P}}^{-1} \hat{\mathcal{P}} \hat{\psi}^{}_{B} \hat{\mathcal{P}}^{-1}\\
        & =\sum_{A, B} \sum_{C, D} (U_{P}^{})^{\dagger}_{A, C} \hat{\psi}_{C} H_{A, B} \hat{\psi}_{D}^{\dagger} (U_{P}^{})^{}_{D, B} \\
        &= \sum_{A, B}\sum_{C, D} \delta^{}_{C, D}(U_{P})^{\dagger}_{A, C}H^{}_{A, B}(U_{P})^{}_{D, B} - \hat{\psi}^{\dagger}_{D}(U_{P})^{}_{D, B}H^{}_{A, B}(U_{P})^{\dagger}_{A, C}\hat{\psi}^{}_{C} \\
        & = \sum_{A, B}\sum_{C, D} (U_{P})^{\dagger}_{A, C}H^{}_{A, B}(U_{P})^{}_{C, B} - \hat{\psi}^{\dagger}_{D}(U_{P})^{}_{D, B}H^{T}_{B, A}(U_{P})^{\dagger}_{A, C}\hat{\psi}^{}_{C} \\
        & = \sum_{A, B}\left( \delta^{}_{A, B}H_{A, B} - \sum_{C, D}\hat{\psi}^{\dagger}_{D}(U_{P})^{}_{D, B}H^{T}_{B, A}(U_{P})^{\dagger}_{A, C}\hat{\psi}^{}_{C} \right) \\
        & = \text{Tr}(H) - \sum_{C, D} \hat{\psi}^{\dagger}_{D}H^{}_{D, C}\hat{\psi}^{}_{C},
    \end{split}
\end{equation}
where we have used the anticommutation relation $\{\hat{\psi}^{}_{A}, \hat{\psi}^{\dagger}_{B}\} = \delta^{}_{A, B}$ between the second and third lines and the unitarity of $U_{P}$ between the fourth and fifth lines. We require $\hat{\mathcal{P}}\hat{H}\hat{\mathcal{P}}^{-1} = \hat{H}$ if our Hamiltonian respects PHS, demanding the conditions that
\begin{equation}
\begin{split}
\text{Tr}(H) &= 0 \\
H = -U_{P}&H^{*}U_{P}^{\dagger}
\end{split}
\end{equation}
i.e. the Hamiltonian is traceless. We have also used the Hermicity of the Hamiltonian in the second equality. Thankfully, these two conditions are complementary, since $H = -U_{P}H^{*}U_{P}^{\dagger}$ implies that our Hamiltonian has a symmetric spectrum.
The interesting thing is that the particle hole operator is unitary and linear in the second quantised picture, but antiunitary and antilinear in the first quantised picture, i.e. $P = U_{P}K$ where $P$ is the first quantised version of the particle-hole operator and $K$ is the operation of complex conjugation.


known public exploits for vsftpd 2.0.1/2.0.5

Question: I somehow noticed that there were numerous reports of security vulnerabilities of vsftpd 2.0.1~2.0.5; however, there just seems to be no public exploits.
The server I am working on has vsftpd 2.0.5 (set up by my supervisor-head administrator), and I am just worried that someone might be able to attack the server...
If there is any known exploit, can anyone provide me with the known links to public exploits? (so that I may make some vulnerability assessment.)
Comment: When you say that there are no public exploits, where are you looking? A google search brings up results.
Answer: Exploit-db finds 3 exploits (click link). 1 for that specific version and 2 for higher versions.
OSVDB shows 11 exploits however you have to click each ID to see which version the exploits are for.
cve.mitre.org also reports 11 exploits. Versions are listed in the description. There are some there specific for 2.0.5.
Answer:
As far as I know there is no as such serious exploit for vsFTPD version 2.0.5 which would allow an attacker to gain access or allow arbitrary code execution, instead I would suggest you to check if this service some how helps attackers to gain juicy information.
Enumerate users, in old ftp versions I have noticed the anonymous accounts are enabled, when you login using anonymous accounts the ftp daemon sometimes leak's original application version and check if that version is vulnerable to any exploit, also check if any other such accounts are working or any other accounts are having weak passwords which can be bruteforced easily.


WiFi Connection's Name

Question: I am Developing a Java ME Application. Here I am using WiFi Connection. Now My Question is how to get a particular WiFi Connections name using Java ME Code ?
My Requirement is for Nokia E5 Device only.
Comment: Have you tried [IAP Info API](http://library.developer.nokia.com/index.jsp?topic=/Java_Developers_Library/GUID-9597E8B4-5551-4D0D-A256-6C045480ED2A.html) ?
Answer: After doing much research work I found that this is not possible in Java ME Technology to fetch the WiFi Connection's Name.
However Similar Library would be com.nokia.multisim.networkid which returns Network ID and Network Short Name.
Answer: I Dont Think so it is 100% possible in J2ME and even though if it has worked and there is no guarantee that it will work on all J2ME devices which has Wifi connectivity.
most appropriate answer i have found , please go through it once.
" Much as I hate to put you through all that grief and then not have a simple answer, I don't have a simple answer.
The reason for that is because Java's networking model is based on TCP/IP, and the TCP/IP architecture is based on the idea that applications will neither know nor care about the hardware details of networking. A typical mobile device may contain several different network interfaces (WiFi, Bluetooth, Infrared, USB cable, and so forth), but when an app wants to contact another network node, the app doesn't know which of these interfaces is actually being used. And in fact, if the OS wants to do so, it can use more than one (in parallel) and/or switch interfaces in and out, based on routing criteria such as best measured data rates. Rather like how cell phones route phone calls.
So basic Java/JME won't know anything about WiFi.
However, there is an extension, specified as JSR 309 (http://jsp.org) that looks like it may help. It supports learning about and controlling the network interfaces themselves. The problem is that not all devices will implement this extension, so it will depend on what device(s) you are supporting. "
Comment: Please check my updation in question.
Comment: its a suggestion given to get control over network interfaces and if you are targeting for Nokia e65 device only then have you tried with this IAP Info API from Nokia ?
Comment: Can you share that piece of code and what error/exception are you getting ?
Comment: Sorry , I can't My Company doesn't allow me for it.
Comment: mean to say , after using IAP APi what problem are you facing ?
Comment: I can fetch the type of network as EDGE or wlan, but i dont know how to get the wlan's name.

WiFi Connection's Name


Can geyser plugins be used on historical data

Question: Per documentation it is said that Geyser Plugin system can be used to offload currently validated data to different databases, however, I do not understand whether it can be used to process historical data starting from the genesis block. And if it isn't possible with Geyser, then how can it be done?
Answer: Theoretically this can be done, yes.  At least so far back as when the Geyser Plugin interfaces were first introduced.  Technically back to genesis if hero wants to build out the infrastructure.
Instead of running the plugin against a solana-validator instance, you'd use solana-ledger-tool to play ledger archives to backfill whatever data store your Geyser Plugin is building.  Given that the binaries and ledger archives have limited compatibility, you can only do this so far back as the first version that the Geyser Plugin interface was introduced, at best.  Less if you need a feature that was added later.
However, there's no technical reason that the Geyser Plugin interface (and its dependencies, as you go back further) couldn't be backported to allow for support all the way to genesis.  It's non-trivial work, but doable for a motivated team.  Not to mention extremely valuable to the ecosystem.
Answer: On startup Geyser plugin receives all account's states. After that, it can be used to receive new account updates, new transactions, or both.
If by historical data you mean previous transactions - they are not possible to get with Geyser plugins.
Comment: Thank you! Are there any other ways to process previous transactions?