Java: having a collection of items, where each item has a field "previousItem", what is the most efficient way to order the collection?

Question: I have a collection of hierarchical items in an unsorted collection. Each of these items has a field previousItem:
public class Item{
   public Item previousItem;
}

What is the most efficient way of processing these items so that the output is a collection, where the Item without any previousItem is the first Item in the collection and each subesequent item's previousItem is the previous item in the collection?
My first idea would be to implement the Comparable interface in the Item class:
public int compareTo(Item that) {
    final int BEFORE = -1;
    final int EQUAL = 0;
    final int AFTER = 1;

    if(this.previousItem==null){
        return BEFORE;
    }

    if(that.previousItem==null){
        return AFTER;
    }

    if(this.previousItem.equals(that){
        return AFTER;
    }else if(that.previousItem.equals(this){
        return BEFORE;
    }

    return EQUAL;
}

and then loop through the items an add them to a TreeSet:
SortedSet<Item> itemSortedSet = new TreeSet<Item>();
for (Item item : itemCollection) {
    itemSortedSet.add(item);
}

Is there a more efficient way (less time to process/number of iterations needed) to order the collection so that they are in logical, hierarchical order?
Answer: Your comparator would not work: it does not provide transitivity, i.e. it will do the wrong thing if you compare items A and C in the case of A->B->C.
If no items can have the same previous item, your Item objects essentially form a basic linked list. If you happen to know which one is that last item, you can start from there with a single loop and unravel the whole structure:
Item last = ...;

while (last != null) {
    result.add(last)
    last = last.previousItem
}

If you do not have a way to find out which item is the last one, then you could use an IdentityHashMap to map each previousItem value to the Item object that uses it:
IdentityHashMap<Item,Item> m = new IdentityHashMap<Item,Item>(itemset.size());

for (Item i : itemset)
    m.put(i.previousItem, i);

Item i = m.get(null);

while (i != null) {
    result.add(i);

    i = m.get(i);
}

This will unravel your unsorted collection starting from the item that has no previous node.
Both methods have a roughly linear complexity w.r.t. the number of items, but they make two assumptions that may not be valid in your case:

That each item can only be the previous item of at most one other node, i.e. that your items are a list instead of a tree.
That there is a single "thread" of items.

If either of these assumptions is not valid you will need a far more complex algorithm to sort this out.
Answer: From what I see, your Item is already implementing a linked-list (if not by name), so the natural (for me) way to put it in a collection is to transform it into a real list recursively. After the items are transformed, you may need to reverse the list, according to your specification.
public class Item {
   Item previousItem;

   public void putToCollection(ArrayList<Item> list) {
     list.add(this);
     if (previousItem == null) {
       Collections.reverse(list);
     } else {
       previousItem.putToCollection(list);
     }
   }
}

Answer: If I understand you correctly, you have a handle on the Item object without previous object. You could just loop through the Items (e.g. with a while-loop) and add them to an ArrayList or a LinkedList, because the add()-Method of those List implementations just appends a new Item at the end of the list. This way, you get through it in O(n)-time.
Answer: You can use a HashSet<Item> in which you initially put all the items. Then you go over the items in a loop and remove every previousItem from your set. At the end you should be left with a single element in the set, the last one, which was not a previousItem for any other item. And then you can simply add items starting from that one and going through the links.


Answer is certainly not of "very bad quality"

Question: I don't know where or how I should say it, but I don't think this answer should have been deleted.
Answer: It doesn't answer the question.  It just says "try this", which is hardly an answer.
Comment: I respectfully disagree.  It *looks* like it's an answer but it really isn't.  It's throwing out two methods to attempt to use without any context into why those methods are necessary, what they do or what relevance they have to the problem at hand.  The answer as presented is less valuable any passer-by since it lacks critical context into what the actual issue was, and how it can be addressed.  This does *not* answer the question.
Comment: @bobrobbob "the only hint to an answer is now lost for everyone" – nothing is stopping you (or anyone else that encounters this audit) from taking that hint and turning it into an actual answer with some context. You might even get some upvotes out of it.
Comment: it answers the question. "try this" is just a figure of speech. like noone here ever uses it
Comment: the question _is_ the context. i understand that the answer as is will not be fit for any passer-by, but it is well enough for me. and the useful information in it, the only hint to an answer is now lost for everyone. thanks for your time
Comment: @Makoto So whenever I've run across answers like this, I've applied [Cody's opinion about rhetorical questions](https://meta.stackexchange.com/a/131996/318307), which means editing the answer into "Do this" instead. Adding in a dash of [Undo's "You're doing it wrong" post](/q/287563/5764553) (looking at the rotten apple), if the answer merely suggests API methods with no context, wouldn't it be a target for downvoting/commenting/editing to add context, not deleting? Am I misunderstanding things?
Comment: @FélixGagnon-Grenier Not ranting. (Try reading it with Spock's voice.) The answer in question was flagged as low-quality and then got deleted from review. bobrobbob here thinks it shouldn't have been deleted, but Makoto's answer says "It doesn't answer the question." My comment was toward that end. I'm genuinely curious to see if I've been doing things wrong.
Comment: @O.O.Balance i am well aware of that. but that rep belongs to the user that is not coming back. note that you're somehow saying the answer was salvageable.
Comment: @bobrobbob Not salvageable in the sense we use the word when reviewing. The information from the answer could have been used to write a good answer – but this would not have meant editing it to make it better – it would have amounted to writing a completely new answer. Hence the rep would be deserved. Look at it this way: You don't get rep for having the right idea, you get it for writing a good answer. An idea that may lead to an answer, a nudge in the right direction – that should be a comment. You don't get rep for those.
Comment: @AndrewMyers I'm not sure what you are answering to here. Like.. were comments deleted? You sound like ranting, but I don't see the cause. The answer here does not seem to relate to what you are saying..
Answer: I agree.
If the answer is correct, it definitely shouldn't be deleted, just because it has a minimal explanation.
Of course the best answers are the ones that provide lots of details, ideally enlightening the reader how to solve similar problems in the future.
But if no such answer exists for the specific question, then one that gives the answer even without explanation is more valuable than nothing.
All this assuming the answer is correct. If It is wrong, there is little sense in keeping it.
Comment: When reviewing "Is this answer wrong?" is not something you should be asking yourself – you may not have the domain knowledge necessary. The question is, is it an attempt at an answer at all, and if yes, does it meet minimal quality standards with regard to formatting and content.
Comment: @O.O.Balance sure, but if you know it is totally wrong/irrelevant, there is little harm in casting a delete vote imo. On the other hand if you are unsure, I would err on the side of caution and let it stay.
Comment: On balance and at a glance, someone saying, "try this" to another person usually indicates *exploratory* answering as opposed to a definitive answer with a minimal explanation.  There's nothing definitive about an exchange like this since its very premise is steeped in trial and error, so correctness **cannot** apply.
Comment: @user000001:  You then inspire a cargo cult of developers who copy "working" code from one place to another with no *inkling* on how that could be possible.
Comment: @Makoto well if it works it works...
Comment: @Makoto no I never said that, but when examining if an answer should be deleted, the first consideration is if it can help someone in the right direction. It doesn't mean that the person using it will just copy paste it, he can do further research himself. Again, I am not saying that "try this" is the best answer, but it's can be sometimes helpful, when nothing better is available. There is also the case where OP had shown so little effort that you can't expect the answerer to do much better (not this case though).
Comment: @user000001 "There is also the case where OP had shown so little effort that you can't expect the answerer to do much better" – in that case, don't answer, vote to close instead.


What is the best way to vent the plumbing for a 1 sink/1 toilet bathroom in the basement?

Question: I am currently finishing my basement, and we plan on putting in a small bathroom. When it comes to venting, I wasn't sure if I needed to run a pipe from the basement, up through the 1st floor wall, into the attic to meet up with the vent stack, or if there was an easier option. I have read a bit about studor vents, but I couldn't find in my local codes whether that was permissible for a toilet. Would I just be better off running the pipe to the attic?
Answer: Under IPC rules (which are the main code in my area, with a few modifications) you can join to a dry vent 6" above the flood rim of the highest fixture on the floor served which typically means somewhere in the 40-48" realm is safe, if you have a dry vent wit enough excess capacity you can access on the first floor level. Wet venting via a vented drain that does not have a toilet above may also be possible - there are limitations on it that are more restrictive than dry venting.
Evidently your local code is also based on IPC, with modifications that probably are different than my local modifications. The 2015 IPC which seems to be what your code is based on (but I have not tracked down your local modifcations.)
Air Admittance Valves (one common brand of which is Studor)(Mechanical Vent is another term you might see used for them in code) are permitted in IPC but may or may not be stricken in local code. I, personally, will always choose a real vent pipe connecting to an exterior vent over a device that can and does fail to work as intended and leaks sewer gas into the house until it's cleaned or replaced to restore correct function. You may do as you please if your local set of codes permits.
Comment: Ideally, **ask a new question for that,** and put the pictures in it. You can link to this question if it helps to clarify any. Given the typical limitations of pictures of a plumbing system in a built house, you might also want to draw a diagram, and indicate what things are connected to which pipes.
Comment: I am leaning more towards a real vent pipe, for the reasons you mentioned. I wasn't sure where the best place to join it would be, would it be possible for me to show some pictures and get some advice?
Comment: Thank you, I will do that.


Do I need a Schengen visa to transit Amsterdam and Paris enroute to Lagos from U.K

Question: I have a UK residence permit with flight details, Glasgow to Amsterdam, Amsterdam to Paris, Paris to Lagos. Do I need a visa?
Answer: Amsterdam to Paris is an intra-schengen flight so yes you definitely need a schengen visa and not just a transit visa but a full Schengen visa. You need to be admitted into the Schengen area before you can board such a flight. The very point of the Schengen area is that in a typical case (these days, not always) after disembarking from a plane you do not need to go through any passport checks significantly speeding up the process (and offloading the immigration staff at the destination airport).


How to get that pretty key name that Blender shows in a keymap button?

Question: Is there a way to get the complex label that Blender shows for keymap items, when the only thing I have is the key type for that keymap?
That is, getting the "Spacebar" string, when all you have is "SPACE" (like from the event.type in a modal handler of a modal operator)?
Answer: Yes, you can get the same displayable key name.
You need to use that "SPACE" string (AKA the event type, which can be anything from the event type constants), as a key in the dictionary of enum items of the EnumProperty type of the bl_rna of the bpy.types.Event struct (phew!).
The path to this dictionary is:
bpy.types.Event.bl_rna.properties['type'].enum_items
To be accessed like this from Python (usually inside the modal() function of your operator, but not necessarily):
>>> eventType = event.type # This is a string. It can be 'SPACE', 'LEFTMOUSE' etc.
>>> enumItem = bpy.types.Event.bl_rna.properties['type'].enum_items[eventType]
>>> enumItem.name # The displayable key name.
'Spacebar'


At what height would a pilot apply TOGA during a go around Vs getting simply vectored somewhere else?

Question: If a pilot has to go around Early in a approach, he can simply be vectored to get reestablish. At what point would the pilot decide to apply TOGA other than obviously at minimums?
Answer: Anytime I want to execute the missed approach I would push the TOGA button anywhere after crossing the final approach fix.  I don't know what specific airplane you fly but the ones I do pushing the TOGA button does these things:

Disconnect autopilot
Sets flight director to 9° nose high in a wings level condition
Sequences the FMS (FMC) to fly the missed approach
Comment: That's how the CRJs work, which have the Collins Pro Line Flight Director.
Answer: When operating into airports with parallel runways airliners are sometimes given a runway change after being established on one ILS.
The procedure to follow is an "ILS Breakout". eg (B767) If done with the autopilot engaged this requires a go-around to be commenced, initially TOGA, followed by a sequence of selections to hold the current altitude and control the airspeed before other selections to recommence a descent and to intercept the ILS for the new runway.
In the B767 the autopilot stays on when TOGA is selected.
A very busy procedure that should not be attempted in IMC below 1500 ft. ie Go-around and follow the missed approach procedure for the current runway.


Bitcoin mining: internet connection status?

Question: How much bandwidth consumption can I expect per 13 Thash/s rig (Pooled). I'm Buying an s9 antminer, and i live in lebanon ( bad connection ).what do u guys advise me to do?
Does the internet speed affect ? What the speed required in order to mine correclty? How much data does it use monthly ?
Note: Assuming that i ll mine 24/7
Thank you so much!
Answer: To clarify, For solo mining a fast internet connection DOES matter, but in the case of a pool, it's a lot less.

On Stratum with variable difficulty, you should need ~1kbps (0.125 KB/sec).  It doesn't matter how fast you are, which is why the new protocols were implemented.  1 GH/s, 1 TH/s, 1 PH/s, with proper server implementation it should all use the same bandwidth per connection.`

You should need barely any bandwidth for pool mining. If you watch packets between your rig and the server, they make up a very small amount of data
(1-10kb?) The requirements are extremely small for most of them. This would be ~10 MB per day.
It also depends on the pool you're going to mine on.


Word meaning "far greater than required or necessary"

Question: Looking for a word that means 'far more than necessary. Like if I needed 5 apples, but got 25, my gain or success would be described as...X. I think I may have heard 'overt' used like this in the past, but not sure. Not exactly like 'major increase', and basically the opposite of 'marginal'. Thank you guys!
Comment: Who is looking? And what is it that you like? And which male members of this community are you thanking, and are you discriminating against the female ones?
Answer: The word I immediately thought of, which sounds similar to overt, is overkill:

[Merriam-Webster]
2 : an excess of something (such as a quantity or an action) beyond what is required or suitable for a particular purpose
    // publicity overkill
    // an overkill in weaponry

In describing the situation in the question, you might way the following:

Buying 25 apples for a pie is overkill.

It has a more literal sense, but is often used in this figurative sense too.
Answer: OED

excessive (adjective)

2. Of qualities, states, actions, magnitudes, etc.

b. Exceeding what is right, proportionate, or desirable; immoderate, inordinate, extravagant.

1875   B. Jowett in tr. Plato Dialogues (ed. 2) III. 681   A single night of excessive rain..left the rock of the Acropolis bare.

Merriam Webster

excessive (adjective): exceeding what is usual, proper, necessary, or normal

Collins:

excessive (adjective)

1 (adjective)  in the sense of immoderate: The length of the prison sentence was excessive considering the nature of the crime.
Answer: Those apples are surplus or superfluous.

Surplus (adjective): More than what is needed or used; excess. [Lexico]

Superfluous (adjective): Unnecessary, especially through being more than enough. [Lexico]
Answer: glut (n.)
1530s, "a gulp, a swallowing," from glut (v.). Meaning "condition of being full or sated" is 1570s; mercantile sense "superabundance, oversupply of a commodity on the market" first recorded 1590s.
Answer: superabundance. noun. A condition of going or being beyond what is needed, desired, or appropriate.


Disable the Research Task Pane in Excel/Office

Question: Can how I disable the Research Task Pane in Microsoft Excel/Office 2003?
Answer: I have fought with this myself for years, but I finally found the answer:

From Word, press Alt + F11 to open the VBA Editor.
Press Ctrl + G to open the Immediate Window.
Type this line and press Enter:
Application.CommandBars("Research").Enabled = False

Answer: Turns off the Research Pane/Pain:
Go to   Add/Remove Programs ---> Microsoft Office ---> Add or Remove Features ---> expand Office Tools ---> disable Research Explorer Bar (there's a red X which you select to disable it.
Worked for me and I was delighted to get rid of the damned thing.
As I understand it you can still access the Research Pane manually (e.g. clicking on its icon). I have not bothered with this to manual access to check it out because I'm hoping to never see this pane again.
Answer: Do you mean to stop the task pane from appearing at Excell startup or disable it altogether?
If you want to disable it, I can't help you, sorry, but if you want it to stop appearing go to "Tools", "Options" menu, then in the View tab, and uncheck "Startup Task Pane."
If it doesn't works, have a look at http://www.computerhope.com/issues/ch000753.htm; I'm told you may have to manually edit the registry in some cases.
(Danger, Will Robinson!)
Answer: You can't disable it. You can only remove all the services it tries to use then keep closing it. It comes up from various key combinations like Ctrl+Whatever or Alt+Whatever.
Answer: Try disabling it by disabling the Bing bar on your browser. That was the only thing I changed and it worked for me.
Answer: You can just try Alt+click on any cell and then go to Review tab and uncheck research button. You will see the pane doesn't automatically show up any more.


Payment options in Website itself

Question: Is there any extension(payment gateways, indian market) available to make the Payment in the website itself like in attached screen shot?
Answer: Magento has the option for Authorize.NET, which will be a payment in your page. You just need to create your account here: http://www.authorize.net/
Another option is to use PayPal Pro account, which allows you to customize the payment form (instead of sending the user to PayPal website): https://www.paypal.com/webapps/mpp/paypal-payments-pro
Comment: Thanks. is Apache server compatible with PCI Compliance?
Comment: PayPal and Authorize.NET are PCI Compliance, so you will be good

Payment options in Website itself


Is it possible to rank down?

Question: I know that we need to win 2 of 3 games to rank up, rigth? like form silver 2 to silver 1.
Is it possible to rank down? like silver 1 to silver 2? There any matches that we need to win to stay in that rank?
Comment: The original question asks about demotion in general, including silver to bronze (yes it's possible).
Comment: That question is for Diamound to Gold and Gold to Silver. i would like to know if the other (Silver to Bronze) is possible and how many matches i need to win to keep in the same division
Answer: Yes it is possible to get demoted
Demotion happens when your current League Points reach 0 and you lose enough games to get demoted. When you are demoted you go to one division below your current and get 75 LP in that division e.g. if you are in Gold II and get demoted you will fall to Gold III and have 75LP.
There is also a demotion immunity grace period for several games, in which you can't get demoted to a lower division, which activates when you get promoted to a higher division. This is to make sure you don't fall to your previous division due to bad luck. However, one will demote out of Masters into Diamond I after playing at least 3 games, then losing with 0LP.
During server issues losing a game and getting "Loss Prevented" prevents demotion and will not count as a game for Promotion Series - you won't lose them due to that game.
As of Season 4, it is possible to be demoted from a tier. If you are in division 5 of a tier and your MMR drops an entire tier, you will be warned about possible demotion. For example, a player in Gold V would receive a warning upon reaching Silver V MMR.

Is it possible to rank down?


Is there a zikr that can erase major sins

Question: I have committed major sins in the past but now want to achive forgiveness please tell me is there any zikr that can help me from erasing major sins? I will also do tauba
Answer: In fact, it means that you regret what you have done in the past and intend to repent. In the Qur'an, God says to the Prophet: Say [that Allah declares,] 'O My servants who have committed excesses against their own souls, do not despair of the mercy of Allah. Indeed Allah will forgive all sins. Indeed, He is the All-forgiving, the All-merciful.39_v53.
Moreover, your Lord will indeed be forgiving and merciful to those who repent after they having committed evil out of ignorance and reform themselves.16_v119
So do not worry about God's forgiveness. He forgives. The first sign of accepting your repentance is to see that you will no longer commit those great sins. This means that your repentance is real.
How to repent of different sins is different; Because there are two major sins, the right of God and the right of the people.
The method of repentance from the sins that are the right of God is real repentance and the intention to leave permanently and not to repeat it, and in cases where an obligatory act has been abandoned, make up for that obligatory act; Such as performing the prayers that he has not prayed and the fasts that he has not fasted, etc., and in the case of sins that are the right of the people, in addition to repentance and remorse, he must fulfill the right of the people, unless the rightful one overrides his right and makes it lawful.
That is, if someone's right is lost or someone's reputation is lost, or if someone or a group has deviated from the right path because of your propaganda, you should. Let them know.
https://makarem.ir/main.aspx?lid=0&typeinfo=42&catid=29319&pageindex=0&mid=321218#114727564_2
Answer: Bismillah Hir Rahmaan Nir Raheem
As Salaamu 3laykum,
I hope you are doing well.

Ibn Mas'ud (May Allah be pleased with him) said:
The Messenger of Allah (ﷺ) said, "He who says: 'Astaghfir ullah-alladhi la ilaha illa Huwal-Haiyul-Qayyumu, wa atubu ilaihi (I seek the forgiveness of Allah, there is no true god except Allah, the Ever-Living, the Self- Subsisting, and I turn to Him in repentance),' his sins will be forgiven even if he should have run away from the battlefield (while he was engaged in fighting for the Cause of Allah)." [Abu Dawud, At-Tirmidhi and Al-Hakim (on conditions of Al-Bukhari and Muslim for accepting Hadith)]. https://sunnah.com/riyadussalihin:1874

Fleeing from the battlefield is a major sin.

Prophet (blessings and peace of Allah be upon him) said: "Avoid the seven sins that doom a person to Hell." We said: What are they, O Messenger of Allah? He said: "Associating others with Allah (shirk); witchcraft; killing a soul whom Allah has forbidden us to kill, except in cases dictated by Islamic law; consuming orphans' wealth; consuming riba; fleeing from the battlefield; and slandering chaste, innocent women."  (Reported in Bukhari and Muslim)

So from this we can deduce we will be forgiven our major sins if we recite the supplication from above.

Have a Nice Day!

Note #1: If you downvote my answer, please be courteous and say why you downvoted in a comment below.
Note #2: This is my own personal answer that I have derived from what I have researched.


Is it OK (from a security perspective) to add only the the server cert to client trusted store with out adding the root Certificate in SSL?

Question: Is it OK (from a security perspective) to add only the the server cert to client trusted store with out adding the root Certificate in SSL?
In this case whether handshake completes successfully?
Comment: Try it and see? But as far as I know that's exactly what happens when the browser presents you an untrusted cert and you click "trust", so this should work just fine.  It can even improve security because only that particular cert is trusted, and not the entire root CA. Should the CA be compromised, attacker certs will still not be trusted.
Answer: Yes.  What you are asking about is often called "certificate pinning".
When you add a signing cert or root cert to your trust store, you are saying, "I trust all certs signed by this cert".  By adding the cert to the client's trust store, you are saying, "I explicitly and directly trust this cert".  In the former, you are implicitly trusting many certs, in the latter explicitly trusting exactly one cert.
There are some things to be aware of.

Some clients might not support this model.  If it's third party software, you'll want to test before you deploy this way
you'll need a secure way to deliver the cert to your client. This mechanism has to be trusted and must prevent other, un-trusted certificates from getting onto the client. Web Browsers get their default certs from the browser manufacturer, your OS manufacturer,or from your IT department. If you're going with web browsers and it's for users outside your company, this will be much harder - they can't just connect to your non-root-chained site get a certificate warning and add the cert to their store, as they will have no way to know if they're connected to a malicious site.
you'll need a secure mechanism to rotate the certificate when it expires or is compromised.
testing your client app may be challenging. You'll want to connect your client app to a test server, which means you'll need a way to set your client app to use the test server's certificate.

You also get some advantages over using root or signing certs in your trust store

if it's your custom app and nobody else's certs are in the store, you get a guarantee that clients are only communicating with your servers (until someone replaces the client's trust store)
root/signing certs use certificate revocation lists for cert revocation, but nobody monitors those. Your approach will simply replace the cert in the client trust stores to effectively revoke a compromised cert.
there is a smaller attack surface. In the web browser standard model, an attacker could go after any trusted root, any explicitly- or implicitly-trusted intermediate cert, or the leaf cert.  With cert pinning, only the leaf cert is a target*

*I intentionally ignore attacks against the software, against weak crypto, and against client trust stores, since that's all common to both scenarios.
Comment: So it is always advisable to add only the root certificate when the cert is signed by an CA and only the Server cert(certificate pinning) when the cert is self signed.
Comment: Those are the two standard models when dealing with certs. Of course, you can have multiple trusted roots, like in web browsers, or you can have multiple pinned certs. You could theoretically have intermediate certs in your trust store, but that would only make sense if you didn't trust the root but did trust the intermediate for some reason.
Comment: Just to reconfirm...So ,If I add the Server Cert or the intermediate cert to the trust store , the validation of the certificate(shown during handshake) will be done till any of the (server cert or intermediate cert) is encountered? ...the validation doesn't require root certificate if we have server cert or intermediate cert in place in trust store?
Comment: Yes, that is correct.  (Don't forget to do regular certificate validity checks, like horsemanship matches common name, current time is between not-before and not-after,  etc,)
Answer: No, it won't work, because trust store accepts only root (self-signed) certificates and entire chain must be validated. And validation will fail if root certificate is not presented in the trust store.
Comment: Thanks for the quick reply...So even though if I add the entire certificate chain to the client trust store..still the client validates the server certificate chain during the handshake till it finds the trusted root?
Comment: yep. In order to trust particular certificate, root certificate from certificate's chain must be explicitly trusted by the client.
Comment: this may be true in some implementations, but it is not true for all client software.
Comment: this would be a very bad implementation. Certificate pinning MUST NOT imply general certificate trust and validation procedures. Certificate pinning can be added on top of standard validation procedures.


Growing Lilies In Greenhouse References

Question: I'm looking for any kind of references (book , video , PDF , ...) for growing lilies in greenhouse. I heard Lilies are like a child and they need standard growing plan such as irrigation plan , ....
Comment: Lillys are very diverse, some like day Lillys aren't particular, others seem to be looking for a reason to kick off.
Comment: Just a tip, around here you'd do much better to ask for actual information instead of references to information. We're trying to be a good resource for people to find answers immediately instead of having to dig through a book.
Answer: This article goes into some detail on growing lilies for the specialty market. Here are the basics:

essentially you are forcing the bulb to produce a flower.  This can be done year round but it is not economical to re-use bulbs. You plant new every crop.
bulbs can be bought year round from growers in cool climates such as Oregon, Washington State and Chile and are shipped pre-chilled so they are ready to plant when they arrive.
remove from packing, dry overnight
use a soil less mix to ensure a well drained soil and plant in raised beds or crates with drip irrigation
heating at night and supplemental lighting may be required depending on your location
harvesting and post harvest handling depend on whether you are focused on the cut flower or live plant market.  Plants are sensitive to ethlyene so do not store with fruit.
the most destructive pest is the lily beetle who is well known to home gardeners for the devastation that it causes on most lily species. Commercial growers prefer to grow under glass or poly with all vents and fans filtered with mesh to avoid the beetles entering the growing area.

If you are considering entering the commercial market to grow lilies remember that producing the product is only half the challenge.  You must have customers secured to buy your product before you plant.  A detailed explanation of floral industry practices is beyond the scope of this question due to it's regional nature.  However, chances are excellent that there is a commercial auction house in a major urban centre near you.  Contact them to find out what cultivars and quantities are in demand by buyers.

Growing Lilies In Greenhouse References


Why are surds put on the numerator in the final answer when it is a fraction.

Question: I have learnt that a fraction with a surd in its most simplest form should have the surd in the numerator and not the denominator? Why is it convention not to leave the surd on the denominator? Is it just arbitrary convention or does it have an actual purpose?
Answer: It is a good practice motivated, at elemental level, by the fact that, for fractions with irrational only at the numerator, we can easily apply the distributive property if it is the case, as:
$$
\frac{3}{\sqrt{2}}+2\sqrt{2}=\frac{3}{2}\sqrt{2}+2\sqrt{2}=\frac{7}{2}\sqrt{2}
$$


Integral of delta dirac function

Question: I try to calculate the following integral:
\begin{equation}
\int^{+\infty}_{-\infty} \frac{x^4 \exp{(ixa)}}{1+x^2b^2} \mathrm{d}x
\end{equation}
where $a,b$ are real positive numbers.
This integral does not converge and I hope that it can be represented by some kind of Delta dirac function. But I don't know how to do it. Any suggestions?
Comment: I added this information in my post.
Comment: I dont believe there is any hope of expressing this as some kind of Dirac delta function. The "singularities" are at $-\infty$ and $\infty$, and no matter what you do with $a,b$, the integrad will not go to 0 "outside $\infty$".
Comment: Could you please provide us with some information as to the values $a$ and $b$ are allowed to attain?
Comment: to isolate the divergent part, i would try to add a small imaginary part to $a\rightarrow a\pm i \epsilon $ and see what happens in the end
Answer: As you said, the integral does not converge, it does not have a rigorous meaning. If you really want to write something other than $\infty$ on the right-hand side, though, you may proceed as follows.
Formally, one can define
$$
\int_{-\infty}^{+\infty}\frac{x^4e^{ixa}}{1+x^2b^2}dx \equiv \left(\frac{\partial }{\partial a} \right)^4\int_{-\infty}^{+\infty}\frac{e^{ixa}}{1+x^2b^2}dx;
$$
now, the integral appearing on the right-hand side is convergent (in fact, absolutely convergent) and we may compute it using complex analysis and contour integration: use a half-circle $C_M$ of radius $M$ in the upper-half plane centred at the origin. By the residue theorem, since the only singularity of denominator lying within $C_M$ is a pole at $z_+=i/b$ (thanks to the fact that $b$ is positive), we have
$$
\oint_{C_M}\frac{e^{i\zeta a}}{1+\zeta^2b^2}d\zeta =
i2\pi \text{Res}\frac{e^{i\zeta a}}{1+\zeta^2b^2}\Big|_{z=i/b}=\frac{i\pi}{b^2(i/b)}e^{-a/b}=\frac{\pi}{b}e^{-a/b}.
$$
Now, dividing the integration contour into the real segment going from $-M$ to $M$ and the big arc of radius $M$, we have
$$
\int_{-M}^{+M}\frac{e^{ixa}}{1+x^2b^2}dx +
\int_0^\pi \frac{e^{iM e^{i\varphi} a}}{1+M^2e^{i2\varphi}b^2}iMe^{i\varphi}d\varphi
=\frac{\pi}{b}e^{-a/b}.
$$
The integral on the arc vanishes as $M\to\infty$ since, exploiting the fact that $a>0$,
$$
\left|
\int_0^\pi \frac{e^{iM e^{i\varphi} a}}{1+M^2e^{i2\varphi}b^2}iMe^{i\varphi}d\varphi
\right|
\le \int_0^\pi \frac{e^{-Ma\sin\phi}}{M^2\left|M^{-2}+e^{i2\varphi}b^2\right|}Md\varphi\le
\int_0^\pi \frac{1}{M^2\left|M^{-2}-b^2\right|}Md\varphi = \frac{\pi}{M|b^2-M^{-2}|}.
$$
Hence
$$
\int_{-\infty}^{+\infty}\frac{e^{ixa}}{1+x^2 b^2}dx = \frac{\pi}{b}e^{-a/b},\text{ for }a,b>0.
$$
By our definition, differentiating four times with respect to $a$,
$$
\int_{-\infty}^{+\infty}\frac{x^4e^{ixa}}{1+x^2b^2}dx  = \frac{\pi}{b^5}e^{-a/b}.
$$
As final remark, if we let $a\equiv |\xi|$, for $\xi\in\mathbb R$, we have, for any test function $\psi$ of fast decrease:
$$
\int_{-\infty}^{+\infty} \frac{\pi}{b^5}e^{-|\xi|/b}\psi(\xi) d\xi =
\int_{-\infty}^{+\infty} \frac{\pi}{b}e^{-|\xi|/b}\psi^{(4)}(\xi) d\xi \\
=\int_{-\infty}^{+\infty} \pi e^{-|s|}\psi^{(4)}(b s) ds \xrightarrow[b\to0^+]{}\psi^{(4)}(0)\int_{-\infty}^{+\infty} \pi e^{-|s|}ds = 2\pi \psi^{(4)}(0),
$$
where $\psi^{(4)}$ means the fourth derivative of $\psi$.
This means that, with our definition,
$$
\lim_{b\to0^+}\int_{-\infty}^{+\infty}\frac{x^4e^{ix|\xi|}}{1+x^2b^2}dx =2\pi \delta^{(4)}(\xi)
$$
in the sense of tempered distributions.
Comment: +1: neat observation concerning the Dirac distribution. Cheers,
Comment: very elegant derivation! Thanks!
Comment: @user2863620 my pleasure. If you like an answer to a question of yours, here on MathSE, you are also allowed to "accept" it, by clicking on the check sign at the top left of it, in case you think it is the best one suiting your request. :) Bye!
Answer: Let's ignore $b$ first (a simple change of variable allows to 'reinstall' it) then :
$$\tag{1}I(a):=\int^{+\infty}_{-\infty} \frac{\exp{(ixa)}}{1+x^2} \mathrm{d}x=\mathcal{F}\frac 1{1+x^2}\left(a\right)=\frac {\pi}{e^a}$$
so that :
$$\tag{2}\int^{+\infty}_{-\infty} \frac{\exp{(ixa)}}{1+x^2b^2} \mathrm{d}x=\frac{I(a/b)}b=\frac {\pi}{b\;e^{\large{\frac ab}}}$$
Should you now choose to ignore the divergence of the integral then you will get :
\begin{align}
I&:=P.V.\int^{+\infty}_{-\infty} \frac{x^4\exp{(ixa)}}{1+x^2b^2} \mathrm{d}x\\
I&=P.V.\int^{+\infty}_{-\infty} \frac{(ix)^4\exp{(ixa)}}{1+x^2b^2} \mathrm{d}x\\
\tag{3}I&=\left(\frac d{da}\right)^4\frac {\pi}{b\;e^{\large{\frac ab}}}\\
\end{align}
that should be :
$$\tag{4}I=\frac {\pi}{b^{\,5}\;e^{\large{\frac ab}}}$$
Comment: I have a question: is the $P.V.$ of the OP's integral, really well defined? As far as I can see, the Cauchy principal value only takes care of setting $\lim_{\alpha\to+\infty}\int_{-\alpha}^{+\alpha}x^4(1+x^2b^2)^{-1}i\sin(xa)$ to zero, by parity, but still has the diverging contribution coming from $\lim_{\alpha\to+\infty}\int_{-\alpha}^{+\alpha}x^4(1+x^2b^2)^{-1}\cos(xa)$. In other words, I can't see how $\cos(ax)$ could provide cancellation of oscillations of amplitude $x^2$ at infinity...
Comment: Yes but you ignore my previous sentence "Should you now choose to ignore the divergence of the integral" : the integral is indeed divergent (this is merely a 'regularization' and the P.V. cancels indeed only the imaginary part).
Comment: Ok, I'm sorry, I was just confused by the use of the P.V. notation in the third equation: it seemed as though the right-hand side was meant to be well-defined. Thank you very much for your clarification!
Answer: In terms of distributions, splitting off the polynomial part, we get
$$\mathcal F\left[ \frac {x^4} {1 + b^2x^2} \right] =
\left( \frac {x^4} {1 + b^2x^2}, e^{i a x} \right) = \\
\pi |b|^{-5} e^{-|a/b|} -2 \pi b^{-2} \delta''(a) - 2 \pi b^{-4} \delta(a),$$
which indeed can be identified with the ordinary function $\pi b^{-5} e^{-a/b}$ for positive $a,b$.

Integral of delta dirac function


Best way to implement Java Observer pattern for complex properties

Question: I'm trying to implement the Observer pattern using JDK Observer/Observable however I'm struggling to see the best way to use it on beans that contains beans as properties. Let me give you my concrete example:
My main bean that needs to be observed for changes (in any of it's properties) is..
public class MainBean extends Observable {
    private String simpleProperty;
    private ChildBean complexProperty;
    ...
    public void setSimpleProperty {
        this.simpleProperty = simpleProperty;
        setChanged()
    }
}

..however when I want to set a new value for anything in the ChildBean it won't trigger any change in the MainBean:
...
mainBean.getComplexProperty().setSomeProperty("new value");
...

The more obvious solution I thought would be to make the ChildBean an Observable as well, and make the MainBean an Observer of the ChildBean. However that means I would need to explicitly call notifyObservers on the ChildBean, like such:
...
mainBean.getComplexProperty().setSomeProperty("new value");
mainBean.getComplexProperty().notifyObservers();
mainBean.notifyObservers();
...

Should I even call notifyObservers() on the mainBean? Or should the call on the complexProperty cascade and trigger a notifyObservers() call in the mainBean?
Is this the proper way to do this, or are there easier ways?
Comment: interesting - I just spent all day writing an `ObservableCollection`, `ObservableSet` and `ObservableMap` to hook into `ChangePropertySupport`. Very similar to this! :-) During bean construction, I register `CollectionListener`s with the `final ObservableCollection`s, which perform a `firePropertyChange` on any change. That way, all `PropertyChangeListener`s on the bean get to see changes in the `Collection` properties.
Answer: Your Observables need to call notifyObservers whenever any of their properties change.
In this example:
mainBean would be an Observer of the Observable complexProperty.
complexProperty would have to call notifyObservers any time any of it's state changed.
If mainBean is also an Observable, it's update method (where it receives the notification from complexProperty or any other member Observable) would have to call notifyObservers to bubble this event up the structure.
mainBean should not be responsible for calling complexProperty.notifyObservers.  complexProperty should do that.  It should only call notifyObservers on itself.
Answer: If you want your MainBean to react when properties on your ChildBeanare modified, you should make the child an Observable.
Your setSomeProperty(...) should then notifyObservers after the property has been set.


Difference between "auf Kosten anderer" and "auf Kosten von anderen"

Question: What is the difference between the two phrases? When do you need to use the preposition?
Answer: Your choice. There is no difference, both expressions mean the same and are used in exactly the same context.
Very much like in English

on account of s.o.
on someone's account
Answer: Auf Kosten anderer is a little more "sophisticated".
Comment: Save the german Genitiv!
Answer: The cases. One is Genitiv (auf wessen Kosten?) and the other is Dativ (auf Kosten von wem oder was?), otherwise both are used interchangeably. None is more sophisticated than the other, it's merely a matter of taste.
Comment: "Von anderen" is plural (of others), weil "vom anderen" would be singular (of the other) and be a concatination of "von dem anderen". "Of another" would be "von jemand/etwas anderem", where you can see the Dativ in the form *anderem*.
Comment: The *other* is Dativ (auf Kosten von wem oder was?).
Comment: Are you sure? It's "von anderen" and not "vom anderen", I thought that would make the difference. But I'm not 100% sure now though.


How to get spacing between characters printed using TextOut?

Question: I'm trying to calcuate size of each cell (containing text like "ff" or "a0"), so that 32 cells will fit into window by width.
However, charWidth*2 doesn' represent the width of a cell, since it doesn't take spacing between characters in the account.
How can I obtain size of a font so that 32 cells each is two chars like "ff" fit exactly into window's client area ?
Courier is fixed-width font.
<code>RECT rect;
::GetClientRect( hWnd, &rect );
LONG charWidth = (rect.right-rect.left)/BLOCK_SIZE/2-2;
int oldMapMode = ::SetMapMode( hdc, MM_TEXT );
HFONT font = CreateFont( charWidth*2, charWidth, 0, 0, FW_DONTCARE, FALSE,
    FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
    CLEARTYPE_QUALITY, FF_ROMAN, _T("Courier") );
HGDIOBJ oldFont = ::SelectObject( hdc, font );

for( int i = 0; i < BLOCK_SIZE; ++i )
{
    CString str;
    str.Format( _T("%.2x"), (unsigned char)*(g_memAddr+i) );
    SIZE size;
    ::TextOut( hdc, (size.cx+2)*i+1, 1, str, _tcslen((LPCTSTR)str) );
}
</code>
Comment: Welcome to Stack Overflow. Please read http://stackoverflow.com/editing-help, it will help you format your questions properly.
Answer: Also see GetTextMetrics
Answer: GetTextExtentPoint32
http://msdn.microsoft.com/en-us/library/dd144938(v=VS.85).aspx
Answer: It seems that you'd want the measured difference in charwidth between a two-character and four-character string.
Comment: I want to know the spacing width between the chars before I specify width for a font.


is there a way to predict the possible modularizations of the brain?

Question: we know that human brain becomes more and more modular during its development. We see similar places for the similar modules in the brain (probably because of the similar inputs and vasculature around these regions in many of the people). I'm just curious about an experiment in which the brain is developing (like 1 years maybe) with the classical system (so have a average human body etc.) but after that it's connected with different inputs. In this situation what do you think about the changes on the brain? I'm sure that neuroplasticity will work but can we predict how its gonna work and will change the functions of the specific brain regions?
Comment: Your claim is perhaps not favored by latest studies such as Haxby et al 2001 "Distributed and overlapping representations of faces and objects in ventral temporal cortex": *The distinctiveness of the response to a given category was not due simply to the regions that responded maximally to that category, because the category being viewed also could be identified on the basis of the pattern of response when those regions were excluded from the analysis... These results indicate that the representations of faces and objects in ventral temporal cortex are widely distributed and overlapping.*
Comment: @mohottnad thank you for your response, I'll check out the article more deeply! Actually, my concern is mainly on the changed-input case. In such a case (when the brain is wired to process the information from the body and specific type of modalities) can the brain changes its network when the coming input and modalities change, or just sinks to the atrophy? (I'm new to the field, so my questions can be dumb, sorry about that. ^_^)
Comment: Welcome to psych.SE.  Are you asking what would happen if we connected an animal's eyes to its auditory cortex and its ears to its visual cortex during development, that kind of thing?  This sort of thing is more common with amputations, where skin and muscle that used to be in one place is effectively "moved" somewhere else, and over a period of weeks or months, the brain adjusts accordingly.  Is this what you had in mind?
Comment: @ArnonWeinberg I was asking exactly about this but in a more extreme conditions (such as transplanting a developed human brain to an cephalopod's body, if that's even possible). (I feel like this question is about the balance between energetical conservation and adaptative/neuroplastical investment but I don't know, maybe I'm using a non-functional perspective.)
Comment: You can modularise pretty much anything even in your conscious mind.
Answer: In addition to Haxby's famous 2001 paper referenced in above comment for the highly distributed and overlapping representations of faces and objects in ventral temporal cortex as a general background, Tanaka's 2003 paper referenced below could further address your particular interest about (visual) input change in the (temporal) neocortex which is the latest evolved advanced critical part of human brain compared to other animals. This is from its abstract:

Cells in the inferotemporal cortex (area TE) selectively respond to complex visual object features and those that respond to similar features cluster in a columnar region elongated vertical to the cortical surface... The enormous number of objects present in nature can be efficiently described by combining outputs of the multiple differential amplifiers in the inferotemporal cortex. The two modes may work in parallel, with a graded balance changing according to the behavioral context.

Thus the response to similar but different complex visual object features is sensitively selected by many distributed and overlapping neurons throughout an entire columnar region of the temporal lobe in cortex.

our visual system can either neglect or amplify differences in input images depending on the behavioral context. Columnar organization in the inferotemporal cortex may be crucial to mechanisms that satisfy these two apparently contradictory requirements... Based on these results, it was proposed (Logothetis, 1998) that some TE cells respond to whole objects which the subjects have used to conduct fine discriminations, while a majority of TE cells respond to features present in images of multiple different objects... The above-described invariances of TE cells suggest that they are actually more sensitive to certain types of deformations than others. The types of deformations that often occur when an object moves around appear to be more tolerated.

By recording two TE cells simultaneously with a single electrode, we found that cells located close together in the cortex had similar stimulus selectivities... In most cases, the second cell responded to the optimal and suboptimal stimuli of the first cell. The selectivities of the two cells differed slightly, however, in that the maximal response was evoked by slightly different stimuli... For example, cells in a column respond to star-like shapes, or shapes with multiple protrusions. They are similar in that they respond to star-like shapes, but they may differ in the preferred number of protrusions or the amplitude of the protrusions... If a set of stimuli that vary not only in orientation but also in all other parameters is used, cells within an orientation column will not show clear similarity in selectivity.

Clusters of cells having overlapping and slightly differing selectivities may work together to confer object recognition abilities that are invariant to viewing conditions... Representation by multiple cells with overlapping selectivities can be more precise than a mere summation of representations by individual cells. A subtle change in a particular feature, which does not markedly change the activity of individual cells, can be coded by the differences in the activities of cells with overlapping and slightly different selectivities.

From above summary it should be clear that massive concurrent overlapping and distributed neural networks at least in the temporal cortex part coordinate to both identify invariant object under different input conditions and select to discriminate any subtle difference simultaneously, which probably is much more complex than your original straightforwardly concentrated and modularized view of its underlying neural network basis.

Reference:
Tanaka 2003, "Columns for Complex Visual Object Features in the Inferotemporal Cortex: Clustering of Cells with Similar but Slightly Different Stimulus Selectivities". Cerebral Cortex, Volume 13, Issue 1, January 2003, Pages 90–99.


call Python script from JavaEE

Question: i create model using sklearn library and i want to run this model in JavaEE application i have been trying Jython, but it's impossible to import some important library like pandas and numpy, so how I can do to call a python script for JavaEE application.
Answer: You should probably ask programming questions on StackOverflow as more people will be able to help you with this kind of problems. As suggested here, you can serialize scikit-learn model to PMML and then execute it using jpmml-evaluator. There are different suggestions in that post, so you should take a look at it and see what works best for your use case.

call Python script from JavaEE


Patent enforcement in a market with only private users and no commercial entities

Question: Here is a patent of charcoal as hydroponic substrate. How can the owner practically protect his rights against infringement by private gardeners? Will he go around looking into people's pots and then sue them? And even if he does - what kind of damage can he claim? The estimated price of the charcoal that he would have sold to the infringer for the purpose of his hydroponic farming?... There are no companies that would sell charcoal for hydroponic gardeners as everybody can produce it easily alone. Can he sue companies that sell generic hydroponic systems/pots and mention in their manuals charcoals as one of many possible hydroponic media?
Comment: Your link doesn't work. Perhaps you could write out the patent name and check the link works.
Comment: Is this the patent? https://patents.google.com/patent/US8544207B2/en?oq=8544207. If so, it seems to be expired for fee related reasons. Also note that everyday charcoal is not the same thing as activated carbon.
Comment: Fixed the link, thank you! The patent mentions also regular charcoal, not only activated one.
Answer: Besides inexpensively going after many end users as EricS answers, another approach is to look for suppliers of the  (non-infringing basic product) who promote the use of it in an infringing process. They might do so by advertising, application notes or consulting with end users.
The manufacturer or distributor isn't performing the method steps, so no direct infringement, but if it is actively facilitating and encouraging others to perform those steps, this is indirect infringement.

35 U.S. Code § 271 - Infringement of patent
(a) Except as otherwise provided in this title, whoever without authority makes, uses, offers to sell, or sells any patented invention, within the United States or imports into the United States any patented invention during the term of the patent therefor, infringes the patent.

(b) Whoever actively induces infringement of a patent shall be liable as an infringer.

At least one actual entity must be shown to be directly infringing or indirect infringement can't be established. But the patent owner does not need to sue any direct infringer, just prove that at least one exists.
Comment: Can you review the last sentence? I think it needs an edit.
Comment: Should be clearer
Answer: The link provided didn't work so I searched and found US8544207B2. It should be noted that this patent does not claim the use of charcoal as a hydroponic substrate. Instead it claims activated carbon fiber. Specifically carbon fiber derived from bamboo. I don't think this is something you can just pick up at the local Home Depot. If you want to use regular charcoal in your garden, this patent won't stop you.
Given that activated carbon fiber is not a commonly available material to the general consumer, I don't think the inventors have much to worry about with respect to home gardeners. You can find it, but generally sold by companies to other companies in the filtration business.
Which brings us to you question about claiming infringement against home gardeners. As I said, I don't think this is an issue with this patent. In any case the patent has expired for fee related reasons. Generally this is because the patent owner finds the value of the patent to be less than the required fees. If we ignore the situation with this specific patent, it is possible for a patent owner to sue end users. Generally the idea is that although they don't realize any useful return on the specific person they are suing, they can take a win in such a case to threaten other end users. Since paying a reasonable licensing fee is much cheaper than fighting in the courts you might derive some useful income from just sending threatening letters. I believe such a strategy is pretty rare, but I found one similar case.
Comment: The title reads "... systems with activated carbon and/**or carbonized fiber** substrates..." - carbonized fiber, is just regular charcoal, contrary to the activated carbon mentioned earlier, as far as I understand.
Comment: BTW, can the owner of an expired patent renew it within the 20 years if he suddenly realizes that it is worth it?
Comment: @user1876484 Activated carbon is not charcoal nor is carbon fibers. The activation process increases the available surface area to carbon dramatically which is why it is useful for filtration. By the way, patent titles are not particularly relevant to what a patent protects. For that, you need to read the claims. For your question about reviving patents, it is a good one and I'd recommend posting it as a formal question. I think the answer is maybe, but I'm not a patent attorney so I can't say under what circumstances you can.


Find the shaded part area?

Question: Two squares of side 5 and 2 respectively. They are touching each other. Diagonals of the square are joined.
find the area of the shaded part?
Comment: Well, the slope of the diagonal is quite easy to calculate ... What have you tried?
Comment: I would start by calculating the height of the triangle that the diagonal makes with the smaller triangle. The slope of the diagonal is easy to calculate, it's $\frac{5}{5+2}= \frac{5}{7}$. What is then the height of the small triangle? When you know its height, you can calculate the area of the small triangle. Subtract that from the area of the small square, and you're done.
Comment: I am new to geometry. I don't know how to proceed with this?
Answer: Hint: The triangles formed by joining the vertices of the squares as shown in the figure are similar.
Answer: Let measure of bases of small triangle be a, the small and big triangles are similar and we can write:
$\frac{a}{5}=\frac{2}{5+2}$   ⇒ $a=\frac{5\times 2}{7}=\frac{10}{7}$
So the area of small triangle is :
$A=(\frac{10}{7}\times 2)/2=\frac{10}{7} $
And shaded area is:
$2\times 2-\frac {10}{7}=\frac{18}{7}$

Find the shaded part area?


What is the poetic technique used in "I know why the caged bird sings"?

Question: In this poem, when comparing the caged bird to suppressed black people in America, is the poet using metaphor or symbol?
Answer: Metaphor and symbolism are related,  but in symbolism,  the thing another object stands for is generally more complex and abstract than in metaphor. Therefore,  in this case, the bird itself represents oppressed black people, so metaphor is used for the specific case you ask about.
Here is some information that supports this contention:
Is there a fine line between symbolism and metaphors in literature? - English SE
The Difference Between Metaphors and Symbols - The Sceptical Prophet
Comment: You may well be right, but it's hard to tell because this answer is so short and unsupported. Could you possibly [edit] to include some backup for your definitions of metaphor and symbolism? Thanks! :-)
Comment: Whoops, knew I shouldn't have written it that fast. Well, I've added some more links that should hopefully give more support.


Any Metadata driven UI sample code?

Question: I am in the process of designing a .net windows forms application that uses metadata to drive the UI. Apart from finding http://msdn.microsoft.com/en-us/library/ms954610.aspx, I have nothing much to look forward to. Anyone here worked on metadata driven User interfaces? What are the implications of following this methodology and any pointers would be greatly helpful.
Answer: The most obvious answer would be that Microsoft have themselves embraced this concept through their use of Xaml in Windows Presentation Foundation which replaces WinForms (to an extent).
If you want to stick to a WinForms, you may want to consider MyXaml which is kind of a homage to Xaml for WinForms!
Answer: You may want to check out Evolutility CRUD framework. It is an open source metadata driven framework for CRUD generating all UI at run-time.
It comes w/ source code (in C# and JS) and many samples.
http://www.evolutility.org
Answer: You may try this with HTA. Sometime back I created a metadata driven application using HTA and XML. I created XAML like structure and HTA-VBScript code to parse this structure and render diffent types of UI elements along with validations.
Answer: Check the Andromeda project out, which does so extensively. Too bad the stack isn´t .NET friendly (PHP, Postgres, Perl).

Any Metadata driven UI sample code?


Expression for a situation where you are too used to your work that you don't see its beauty/potential

Question: I am working on my first production mobile app (Android). The UI is okay (to me), but when I show my friends they are amazed by it and tell me how beautiful it is. Since I'm the one creating it and I see it every other minute, it is understandable that I have gotten used it that it's just, ordinary. What do you call this? I know it is also something people in arts experience.Is there a name for it?
Comment: Something along the lines of [_familiarity breeds contempt_](http://www.macmillandictionary.com/dictionary/british/familiarity-breeds-contempt)?
Comment: No, that kinda means you get too close to someone and they no longer respect you.
Comment: No, [Collins](https://www.collinsdictionary.com/dictionary/english/familiarity-breeds-contempt) licenses Gnawme's sense also: 'Familiarity is used especially in the expression familiarity breeds contempt to say that if you know a person or situation very well, you can easily lose respect for that person or become careless in that situation.'
Comment: Thanks everyone for your answers.But I think @NIkki's perfectly describes what am looking for
Answer: Perhaps you would describe this situation as you can't see the forest for the trees. (dictionary.com)

An expression used of someone who is too involved in the details of a problem to look at the situation as a whole

This expression does have a bit of a negative connotation, but I think in this case it's not too negative for what you've described.
Comment: I think it's something along that line.Major difference is this isn't a problem am trying to solve.I've just gotten too close to something that I no longer appreciate it.
Answer: I couldn't readily find a reference for it, but what you're looking for may be too close to see it and variants. You need other sets of eyes to help you see what you have lost the ability to see by virtue of being too invested in something or having been over the same ground too many times. I have used and heard this term often in connection with the development of documents, which are analogous to your UIs. Getting external feedback early and often, long before you lose the ability to see whatever it is you're producing, is key to success.
Comment: I'll agree with that, Richard, but I'm also aware that the originator of something (whether its a work of art, a utilitarian object, a piece of software or even a performance) is often aware of flaws or weaknesses in the product that other people, not being so closely involved, do not perceive.
Comment: @BoldBen True. Good point.
Answer: You've plainly become insensible to the beauty and uniqueness of your creation (sense 3):

unaware; unconscious; inappreciative: We are not insensible of your kindness.
Answer: A few possibilities spring to mind:

objectivize: To make objective or impersonal; objectify

Your first production mobile app is something you have objectivized, at least for the time being, since you are in the process of bringing it into being. Naturally, you need to step back and ask questions such as, How can I improve it?; What is wrong with it?; and Is the cost of making it available prohibitive?

to take for granted: to underestimate the value of: a publisher who took the editors for granted.

To take something (or someone) for granted means in your case that you are temporarily underestimating the value of your mobile app until you consider it a viable and sellable commodity (in other words, ready for the marketplace).

to become habituated: the process by which one becomes accustomed by frequent repetition or prolonged exposure.

Habituation need not necessarily be a bad thing. Habituation causes you to see and do things over and over again--as with the application of the scientific method to some undertaking, for example--so as to keep your feelings, which can often prove distracting and unproductive, in check.

to become oblivious to: lacking conscious awareness; unmindful: oblivious to her surroundings; oblivious of the criticism against him

I insert this word as a possibility, since you seem to lack conscious awareness of the felicities surrounding this "app" you're currently working on. True enough, some developers or inventors become enamored with their app much too soon. Consequently they find objectivity vis a vis their "baby" difficult to assume. In your case, however, you seem to be keeping your distance from subjectivity and pride in your accomplishments until you've finished your masterpiece.
Answer: you are jaded.  Merriam-Webster

made dull, apathetic, or cynical by experience or by having or seeing too much of something

Example (made up):

After four weeks in the Seychelles, I was jaded and oblivious to its
  extreme beauty; the real world was an enormous shock when I returned
  to it.

If you have to go back to an earlier version of your app, you will be in shock too.
Answer: How about Blasé.
Also according to Macmillan dictionary:

Blasé : Adjective
  not excited, worried, or enthusiastic about something that most people think is exciting, worrying, or impressive, because you have done it many times before

You are getting blasé about your creation.
Comment: "having or showing a lack of excitement or interest in something especially because it is very familiar"...This is it.


Multiple ways of finding Big O of a function

Question: I'm struggling with understanding Big O and I'm unable to quite comprehend the multiple ways that I read, and watch, that are used to find the Big O of a function. It seems that every video or post has a slightly different way of doing it.
Some: Count the operations line by line.
Others, count assignments, multiplications, and additions.
I know this question might be downvoted/closed but I feel I really need an answer specifically to my questions in order to completely understand it.
In this psuedocode taken from https://i.stack.imgur.com/BQeQH.png
function sum(list):
    sum = 0;
    foreach element in list:
        current = element
        add current to sum
    sum = sum * 1
    return sum
endfunction

The author states that the time is 1 + n * 2 + 2 because it sets sum to 0, which takes one operation, it iterates over the list, performing two operations each time, and then, it performs two more operations.
I don't necessarily see how the author gets two operations, instead of 3, that is... current = element is one operation, and, in my opinion, add current to sum is two operations (assignment and addition). As well as, sum = sum * 1 the author states this to be one operation, but I believe it to be two, and return sum another operation. Thus, the time should be 1 + n * 3 + 3.
If anyone could please tell me if I am not understanding why this should be two operations, or if it i really three?
Also, from reading I've noticed most people dont tend to include comparison as an operation. Is it alright to ommit comparison?
And finally, the page at http://isites.harvard.edu/fs/docs/icb.topic780601.files/time_analysis_matrix_multiplication.pdf seems to be the most helpful reference I've found, but they calculate the Big O a totally different way. They calculate the additions, multiplications, and assignments (again ommoting comparisons) and then add them together.
For the code:
for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
        c[i][j] = 0;
        for ( int k = 0; k < n; k++ ) {
            c[i][j] += a[i][k] * b[k][j];
        }
    }
}

It says n^3 multiplications... 2n^3 + n^2 + n additions... n^3 + 2n^2 + n + 1 assignments...
Removing coefficients and all but the largest term:
It says
O(n^3) multiplications + O(n^3) additions + O(n^3) assignments = O(n^3) overall time complexity.
When adding these, is it technically n^3 + n^3 + n^3 = 3n^3 and removing coefficients, this leaves us with n^3? I am asking because I don't see how mathematically n^3 + n^3 + n^3 = n^3.
The way I've found it most helpful to do it is how the page at harvard does it: Counting additions, multiplications, and assignments. I was wondering if there are many ways to do it, and if this is one way that would yield the correct answer every time? This is because for the first psuedocode example, the equation we get would be different (pre removing coefficients and all but largest term).
So if I were to do to the first psuedocode example the way that it's done in the harvard document, I would get:
Multiplications: sum * 1... happens 1 time.
Additions: add current to sum, happens n times.
Assignments: sum = 0... happens 1 time. current = element, happens n times... add current to sum... happens n times.
1 multiplication + n additions + 1 + n + n assignments = 2 + 3n
Removing coefficients and all  but largest term: O(n).
Note that I didn't include the return statement in the equation, and i also didn't include the addition that happens n times when element is incremented. Really, I don't know exactly what I need to keep and what I need to discard.
Could someone please tell me how I would be able to do the above, but be correct? What should I ommit, and what should I keep? And What is the easiest way to find the Big O? Like in the first example, like in the harvard example, or another way? I feel like I can relate best to the harvard example, however, I need to know what the rules are when doing it.
Thanks.
Comment: Could you please accept an answer or provide feedback so this question can be completed? Thanks.
Answer: O (n^3) doesn't mean n^3 operations: It means the number of operations is less than some unknown constant times n^3. Therefore O (n^3) + O (n^3) = O (n^3): The first is less than some constant times n^3, the second is less than some constant times n^3, and if you add them, the sum is less than some (larger) constant times n^3.


What are the real reasons for having oral arguments?

Question: I assume certain arguments sound great on paper but fail miserably when spoken aloud.  I assume that's why the courts do oral arguments.  Can you list some famous arguments that sound good on paper but which are lousy when spoken aloud, along with your answer?
Answer: Your assumptions are incorrect.
Courts allow oral arguments (when they do allow them) so that attorneys have a chance to better address a judge's concerns.  The idea is that it lets an attorney not only present the core of his case, but it also lets him address any problems with his reasoning that the judge may have or help the judge explore a complicated question.  Without that all you have is the back-and-forth in writing with opposing counsel, which is useful, but may not actually address the issues that are important to the judge.
There is some difference in how you present arguments on paper as opposed to in oral argument, but the distinction is largely one of style rather than substance.  An argument that is great on paper is still great when presented out loud, you just present it differently because you are presenting it in a different medium.
For example, you have to present oral argument with the assumption that the judge may interrupt you at any time to ask a question they are interested in, derailing your entire pre-planned argument into a tangential point the judge considers important.  This is great because it lets you address what the judge is concerned about, but it requires a different preparation and some changes to the format of your argument.  For example, while you will front-load both oral and written arguments with a roadmap, both your roadmap and your first sentence are much more important in oral argument.
Answer: The use of oral argument depends upon the court. In the Supreme Court nearly all cases have oral argument. In the Circuit's the vast majority of cases do not get oral argument. In the District Court, the judges don't want to see the lawyers if they can avoid it.
A District Court oral argument is invariably Q&A and is held only when the judge has questions.
In the Supreme Court and Circuits, oral arguments are short presentations given by the lawyers to highlight key points; presentations that get interrupted.


Mating patterns and genetic superiority

Question: In peacocks and peahens, the peahens prefer mating with peacocks having a large and bright tail. But how is having a large tail an indicator of genetic "fitness" (in survival terms) ? If having a large and bright tail is not related with genetic superiority, then what is the point of having the mating ritual?
Answer: Darwin thought quite a bit about this. He even said "The sight of a peacock makes me sick". https://www.ncbi.nlm.nih.gov/pubmed/10824193
He added to his ideas about natural selection to include sexual selection. Traits selected by females, even when they are non-adaptive for males, will increase the males fitness (as defined by his number of offspring). There is also the idea that perhaps possessing such an outrageous and non-adaptive tail proves that you a good mate, the same way we would think that a guy who could win a sprint while carrying barbells must be superior.
Answer: Evolution of traits under sexual selection is relatively complex subject that isn't easily summarized in a post. In short, these are the most important concepts you will want to read about; Fisherian runaway (aka. runaway selection), the sexy son hypothesis), the good genes hypothesis and Zahavi handicap principle.
All these concepts are somewhat related and the semantics can quickly become a little complicated and has been subject to a number of papers (e.g. Kokko et al. 2003). My understanding of the semantics details is limited. To my understanding, the Fisherian runaway selection and the sexy son hypothesis are very similar and the good genes hypothesis and Zahavi hanicap principle are related. What you will be most interested in is the Fisherian runaway selection.
I will below just cite some popular sources and I will leave to you the pleasure of understanding and misunderstanding the differences between these concepts :)
evo101 > Fisherian runaway

Imagine a bird population in which females choose mates at random. Males with slightly longer tails fly a little more adeptly, avoid predation, and so, survive better than males with slightly shorter tails. In this situation, a gene for female choosiness (longer tail = sexier) will be favored, since by choosing a long-tailed male she will have sons with longer tails. This trait will spread through the population until most males have long tails and most females prefer long-tailed mates. So far so good.
However, once this has happened, the process may run out of control, until the male trait becomes so exaggerated that it is disadvantageous. In other words, female preference, instead of survival advantage, may begin to drive the evolution of ever-longer tails, until males are encumbered by showy plumage that no longer helps them avoid predation.

evo101 > good genes hypothesis

Imagine another bird population in which females choose mates at random. Some males in the population have better genes for survival than others, but it is difficult to tell whether a male has good genes or not. In this scenario, long tails make it more difficult to survive�they are costly to produce and maintain. Because they are so costly, only males with good genes have the extra resources to produce them. In this situation, a long tail is an indicator of good genes. A gene for female choosiness (longer tail = sexier) will be favored, since�by choosing a long-tailed/good gene male�she will have sons with good genes. This trait will spread through the population until most females choose long-tailed mates and males that are able to produce long tails are favored.
If females choose males with "long and costly" tails, they are guaranteed to get good genes! If they choose males with "short and cheap" tails, they may get good or bad genes.

Wikipedia > Sexy sons hypothesis

The sexy son hypothesis in evolutionary biology and sexual selection—proposed by Ronald Fisher in 1930—states that a female's ideal mate choice among potential mates is one whose genes will produce male offspring with the best chance of reproductive success. This also implies that a potential mate's capacity as a parental caregiver or any other direct benefits the father can offer the mother, such as nuptial gifts or good territory, are irrelevant to his value as the potential father of the female's offspring. Fisher's principle means that the sex ratio (except in certain eusocial insects) is always 1:1 between males and females, yet what matters most are her "sexy sons"' future breeding successes, more likely if they have a promiscuous father, in creating large numbers of offspring carrying copies of her genes

Wikipedia > good genes hypothesis

"Good genes" theory proposes that females select males seen to have genetic advantages that increase offspring quality. Increased viability of offspring provides compensation for any lower reproductive success that results from their being "picky". The good-gene hypothesis for polyandry proposes that when females encounter better males than their previous mates, they re-mate in order to fertilize their eggs with the better male's sperm.

Clearly, the good genes theory is not the one you are interested in with the peacock tail example.
Wikipedia > Zahavi handicap prinicple

The handicap principle suggests that reliable signals must be costly to the signaler, costing the signaler something that could not be afforded by an individual with less of a particular trait.

Note that the term "genetic superiority" is never used in evolutionary biology. In fact the term sounds very social science related and make me think of the ugly side of eugenics. We usually talk about "fitness difference", "low fitness" and, "high fitness".

Mating patterns and genetic superiority


Broken mango seedling stem

Question:
I broke my mango seedling stem tip. Stem is still growing but it has no leaves at all. And to tell you the truth i don't understand from where could the leaves grow. Any  ideas on this matter would be welcomed.
Answer: I have damaged mango seedlings before... What usually happens is the stem will keep growing for a while and might even have a little branch... but the main growth will likely come from another stem that will emerge from the middle of the seed somewhere, but if you started another one today it would win in a race to 24 inches (60cm).

Broken mango seedling stem


How do I scale without loosing my animation?

Question: I have been trying to set the scale of this part from -1.000 to 1.000 but when I do that the faces flip inside out and the object completely looses it's rotation.
Is there any way to do this, it is absolutely necessary for my project as it is for Flight Simulator and it does not read the scales as blender does and everything needs to be at 1.000.
Comment: Is Apply Scale(with Ctrl-A) helpful? This keeps the current size and sets the scale as default.(Sorry. forget it. I tried this on myself and didn't work)
Comment: As a rule, and in future projects, you should always keep your scale at 1 unless you have a strong reason not to.  Read: https://blender.stackexchange.com/questions/7298/why-is-it-important-to-apply-transformation-to-an-objects-data
Comment: Scale to 1 in object mode, then enter edit mode, select all and scale to -1,  the object will keep the scale but the mesh will be flipped the way you had it before.
Comment: Ok if I do that the faces are correct and animations but now it is misaligned . picture above ^
Comment: Enter edit mode and align the geometry there.
Comment: Honestly that does not work for me, I am just going to give up on modeling, I have been stuck at this for 3 years now.
Answer: I recommend using python. (mainly based on How to get keyframes and related information?)
<code>for ob in bpy.context.scene.objects :
    if ob.type in ['MESH','ARMATURE'] and ob.animation_data:
        for fc in ob.animation_data.action.fcurves :
            for key in fc.keyframe_points :
                bpy.context.scene.frame_set(key.co[0])
                if ob.scale[0] < 0:
                    ob.scale *= -1
                    ob.keyframe_insert(data_path = 'scale')
</code>
The flow of this code is something like;

look for an object
get the frame number with keyframes
rescale it if the scale is minus
overwrite keyframe

I've tried this with an animated .blend file in blender2.79 and it worked.
Comment: Intuitive is a subjective term. I find it more intuitive to have the core functionality of a bit of code outside conditionals. See https://github.com/golang/go/wiki/CodeReviewComments#indent-error-flow for more motivation (the page is about Golang, but the principle can be applied to many languages).
Comment: If you flip the conditions and use the `continue` statement, the main code can be unindented by 2 levels.
Comment: I think I got what you mean but I am not quite sure whether it is neccesary. Especially for the first "if", isn't it better to stick with the original code in order to keep it intuitive?
Answer: This will only work if rescaling is not an integral part of your animations. Given that you've stated that the game doesn't use scaling, I'd hope that is the case.
If so, the first thing you want to do is clean up your animation keyframes by deleting the scale keyframes. For future reference, don't add keyframes for properties that you aren't going to use. After that, all you need to do is apply the scale by selecting the objects, pressing Ctrl+A and selecting "Scale" in the menu that appears.


Flashing of microcontrollers

Question: I have seen some micro controllers can be flashed with USB port alone with some driver software. But for some micro controllers we have additional interface hardware for flashing between the PC USB port and the micro controller pins. Why this difference? Specific example is arduino which can be flashed directly from the PC, whereas freescale micro controllers need additional hardware for flashing and debugging. Can all micro controllers be flashed with USB port alone with specific driver software?
Comment: Because some fish are grey and some fish are red.
Comment: Arduino can only be flashed directly because of a bootloader burned on the chip, and a USB to serial converter on the Arduino board... So I would argue it is not direct...
Answer: An arduino is not a plain micro-controller, so you are making a strange comparision here. An arduino Uno has a pre-installed bootloader in the Atmel ATmega328 micro-controller, plus an USB-to-serial interface (separate chip, for instance a CH340). With those two items added, ANY micro-controller can be flashed directly from a PC.
Answer: Not all MCU even have USB. But anyway, you are talking about boot loader, which is a piece of software that is preprogrammed, sometimes in ROM, and is ready to receive a file on power up. Sometimes from USB, sometimes from other ports. I think today really many kinds of MCUs come with simple boot loaders, but still not all of them.
Comment: No I am not saying about USB port on the micro controller. So, if I understand correctly boot loader is only for flashing the code, I cannot debug the code? For debugging I am assuming we should require some additional hardware interface like Jtag?
Comment: JTAG is most common interface for debugging, but JTAG cable itself is not enough. You would also need development environment and source code.
Answer: It really is just about if the manufacture decided to put this feature on. Sometimes it is left out on smaller devices in order to save space or reduce power use as in most cases USB communication is done with a dedicated co-processor of some sort.
I also want to add not all free-scale boards need additional hardware. The K22F, K64F and KL25Z along with many other development boards they offer can be flashed over USB. I only list those as they are what i've recently used. The only thing is if you are running a RTOS then you may need additional hardware to view things like how much CPU time each thread is using. However you can still do the normal break-point style debugging on any of them with or without a RTOS.
Comment: I am sorry, I am confused, I am speaking in terms of both flashing and debugging. When I am saying debugging, I mean I can put breakpoints, watch variables etc. Can this be achieved without Jtag also? Please help.
Comment: Freescale boards can debugging/flashing with their "OpenSDA" usb port. So if the board has this, then yes you can program and step though the code, place breakpoints while its running to look at variables and the state of the device. Jtag is sometimes needed for more advanced debugging when your running an RTOS, if you don't know what an RTOS even is, then do not worry about it.

[Here's a link to a walk though of how to do it](http://mcuoneclipse.com/2013/05/17/cmsis-dap-with-iar-and-the-kl25z-freedom-board/)
Answer: Whether a micro-controller can be flashed over USB or not depends upon its construction and whether original manufacturer allowed this or not. However it can be modified by end user as explained below.
Arduino is based on atmega IC from Atmel. In arduino UNO, they use Atmega328P. These ICs have been designed in way so as to listen on their SPI ports during start up for any incoming data/code. If they receive a valid data, they will get re-programmed. Arduino guys wrote a small piece of bootloader (consider a tiny OS for uC). This bootloader adds some extra features. It tells the micro-controller to listen on UART (Serial Tx Rx) pins as well for any valid code once the micro-controller restarts. And that's how arduino boards can be programmed over serial communication.
Also, arduino isn't directly being flashed over USB directly. It's being programmed over serial. Arduino has some extra circuit - USB to Serial converter. This is responsible for converting the USB data (which goes from your PC) into Serial data (which can be understood by atmega 328).
If you start writing your custom bootloader, you can use some other features as well. For ex - Your bootloader code can force the IC to start as i2c slave with a predefined address and some i2c master can send code to it. Or, you can implement software serial on pins other than Tx Rx to burn your code.
However, even with all these in place, what manufacturer has made will always stay unless manufacturer allows you to override that. For ex - Even though Arduino is flashed over Serial, you can still use SPI lined to dump code into it using ISP. This is what allows you to burn a fresh bootloader in case something bad happened to the bootloader code.

Flashing of microcontrollers


How to run SQL PLUS in ubuntu 14.04

Question: I have installed SQL PLUS from instructions I got from hereSQL PLUS .. BUt now I don't know how to start whenever I start it using sqlplus64 command it asks for username and password which I don't get during it's installation.
Now I want to know how to start SQL PLUS
Answer: Your default users are sys and system.  According to the Oracle website the passwords are displayed in a message during installation, but I guess you didn't see it?
It used to be that the default users had default passwords. For sys it was: change_on_install and for system: manager.  As you can guess these weren't changed on install, which generally caused a major security risk so maybe this is why Oracle stopped using them.
So my advice would be:
- try the above default passwords and hope they work (which is unlikely);
- reinstall the database and look for the message giving you passwords.
Once you are logged in as sys, create a day-to-day user and use it for your project.  Don't use sys or system - they are too powerful and to be used for administration only.
Comment: I guess they have changed the password because they don't work. what to do?

How to run SQL PLUS in ubuntu 14.04


Display required fields

Question: Is there any class for highlighting required fields in Qt? For C# there's ErrorProvider. Does Qt has anything similar?
Answer:
For C# there's ErrorProvider. Does Qt has anything similar?

Not that I'm aware of.
Probably the easiest way is to use QWidget::setStylesheet() to set a background (or whatever) to highlight the required fields.
Adding an icon next to the required field -- a red asterisk, say -- would be fairly straightforward: create a Field class using a horizontal layout with a required-field icon widget, a label and a 'field' widget, and give it a setRequired(bool) function.
I guess you could also use QStyle to create a custom widget.

Display required fields