Restore tmux session after reboot

Question: Is there any way to save a tmux session? In other words, if I reboot the computer, will I always lose the sessions?
Answer: Yes, if you reboot you computer you will lose the sessions. Sessions cannot be saved.
But, they can be scripted.
What most do in fact is to script some sessions so that you can re-create them.
For instance, here's a trivial shell script to create a session:
#!/bin/zsh

SESSIONNAME="script"
tmux has-session -t $SESSIONNAME &> /dev/null

if [ $? != 0 ]
 then
    tmux new-session -s $SESSIONNAME -n script -d
    tmux send-keys -t $SESSIONNAME "~/bin/script" C-m
fi

tmux attach -t $SESSIONNAME

Here's what it does.
First, it checks if there's any session already with that name (in this case, the very original name is "script") with tmux has-session.
It checks the return code. If there's a ongoing session with that name already, it skips the "if" cycle and go straight to the last line, where it attaches to the session.
Otherwise, it creates a session and sends some keys to it (just running a random script for now).
Then it exits the "if" block and attaches.
This is a very trivial sample. You can create multiple windows, panes, and the like before you attach.
This will not be the very same thing you asked for, though. If you do any changes to the session, for instance you rename a window and create a new pane in it, if you reboot those changes won't of course be saved.
There are some tools that ease the process of scripting sessions, although I prefer to do things manually (I think it is more versatile). Those tools are Tmuxinator and Teamocil.
My main source of informations was "The Pragmatic Bookshelf" Tmux book.
Comment: Tmux doesn't know anything about the state of processes you may have had running. You could script having the *same* files open by having the 'send-keys' or 'split-window' command be 'vim file1 file2 file3' or look into your editor's session management (vim -S and the like)
Comment: @DominykasMostauskis that command _sends_ key presses to the specified session. It's like entering the session, and inputing those very keys from the keyboard. In this case, you send "~/bin/script" followed by Enter.
Comment: doesn't sound like that will do anything if I want to restore a session with 5 files open. No way to do that?
Comment: What is the purpose of the `tmux send-keys ...` line?
Comment: can I have the script do ssh login with username and pass? (I know its not secured just want to know if its possible for systems where i don't care about seurity but still have to have user and pass).
Comment: @jas I use key pairs only (passwordless login) and put an alias like this in my .bashrc to SSH to my local VM. Then I just type 'sshlocal' and I'm in:

`alias sshlocal='ssh myname@localhost -t "tmux new-session -A -s main"'`
Answer: I wrote a simple bash script that persists open tmux sessions, windows and current working directories in each.
Call it like so manually or periodically from cron (because you might forget):
tmux-session save

It will write to ~/.tmux-session. Restore them after reboot like so:
tmux-session restore

I find this much better than a several hundred line long Perl script.
Comment: This works for mutltiple tmux sessions, but it does not save panes within each window.
Comment: Your `tmux-session` script is now in my dotfiles project. Thanks! https://github.com/ElectricRCAircraftGuy/eRCaGuy_dotfiles
Comment: @mislav you've had a TODO in that file since 2013. May I recommend https://todoist.com
Comment: Is this only if you have one tmux session though?
Comment: many thanks for the script @mislav. I saved the script as .zsh and ran `~/.tmux-session.zsh save` in the terminal without errors. Then restarted the computer and then open tmux interminal and ran `~/.tmux-session.zsh restore` and got `width invalid` as a message (with one additional window created in main directory. But the saved session (with 3 windows and 2 panes in each) was not reloaded. Do you have an idea of what could have gone wrong?
Comment: I just changed the extension from `~/.tmux-session.zsh` to `~/.tmux-session` and got a serie of error messages `~/.tmux-session: line x: y: command not found` (where `x` is between 0 and 27 and `y` is between 0 and 2 (for 2 window, one with 2 panes, the other with one pane)
Comment: This was very useful. Thanks! The tmux save format looks to have changed, so I made a minor change to the restore script.
Comment: It saves the session tabs and directories but that's it. It's a good start though.
Answer: I wrote a tmux plugin that enables you to save complete tmux environment and restore it later.
It strives to be really detailed so that you have a feeling you never quit tmux.
https://github.com/tmux-plugins/tmux-resurrect
Update: now there's a tmux-continuum plugin that performs automatic background saves of tmux environment. Optionally it also *automatically* restores tmux env after computer reboot.
Comment: @bruno-sutic whats the diffrence between your plugin (tmux-resurrect) and tmux-coninuum?
Comment: This plugin is not bad, but it did not restore all my programs. Will read more of your docs and maybe submit an issue on github.
Comment: @Arne Depending on the program, this may require program checkpointing. Instead, I would recommend configuring your programs to restore - persistent .vimrc files and cursor positions for vim, etc. - and storing the tmux pane_current_command for programs like man that can be re-opened. Checkpointing is very complicated in my opinion, but worth looking into in any case.
Comment: Currently I needed to patch continuum like this to make it work https://github.com/tmux-plugins/tmux-continuum/blob/master/docs/continuum_status.md
Comment: I had some problems with bash commands history reloading (when using set -g @resurrect-save-shell-history 'on') and generally with history persistence when switching among terminals in tmux. See [this thread](https://github.com/tmux/tmux/issues/1671) and especially its 5th comment to see a workaround (or hack) I successfully used to overcome this problem
Comment: When using my workaround script I also suggest modifying tmux-resurrect plugin by disabling saving of bash history (only loading should be enabled, my script handles history saving after each command). I.e. in current version of tmux-resurrect you should delete lines 299-301 `if save_shell_history_option_on; then ; dump_shell_history ; fi` in tmux-resurrect/scripts/save.sh. The history works without modifying the plugin too but the history files get large and unclean after several tmux environment saves (and can cause performance issues because my script reloads history after each command).
Comment: Looks good. Thanks!
Answer: tmuxinator is a tool written in Ruby, that could be used to create and manage tmux sessions with ease. It could be used to create a project, which could later be instantiated as as tmux session.
Answer: Consider this partial solution found here
The author creates a function that saves the history of the tmux session in order to persist the state of the tmux session post a server reboot.
Comment: Could you please post what they say? Links can rot.
Comment: @greg Your link returns 404
Comment: Here's a related github link from that author: https://github.com/edsantiago/tmux-session
Comment: @cpast: This is true, but comments can also rot. Best to give both :)
Answer: I successfully use https://github.com/jimeh/tmuxifier for recreating sessions. This can be installed without ruby, just using git.
Samples are pretty self explanatory, e.g.: https://github.com/jimeh/tmuxifier/blob/master/examples/example.session.sh

Restore tmux session after reboot


Purity of revenge won't start. Skyrim: 360

Question: Ok, so I completed the helm of winterhold quest and it won't let me start purity of revenge. I waited 30 in game days and nothing. And since finding the problem, I have already defeated alduin and accomplished so much so reloading a save isn't an option. Any ideas?
Answer: This quest has significant bugs that can prevent it from ever starting. For your situation in particular, it sounds like you are stuck and won't ever be able to start it on this save:

If Driftshade Refuge has already been cleared, this quest cannot be started normally without a workaround[…] (you will have to revert to a slightly earlier save to do this).

Since you probably cleared Driftshade Refuge during Helm of Winterhold, then only reverting to a previous save or using console commands (on PC only) can make Purity of Revenge start.


Monopoly Deal Discarding Extra Cards

Question: What happens if a player doesn't discard the extra cards (more than 7) at the end of his/her turn and non of the other players catches that player?
But they do later...
1. When others have started their turn?
2. When it's the player's turn again who didn't discard, but the other player catches the extra cards then?
Answer: I'm not sure what you mean by 'catches'  to me that sounds you think its the other players responsibility to stop cheating. Checking the rules from here and here (I couldn't find a copy of official game rules on a quick search)  It reads that a player is not allowed more than 7 cards.  This is more commonly called a 'hand limit' in other games.
There isn't anything that says other players have to 'catch them'  to enforce a rule.  Nothing says you can have more than 7 cards if no one spots them.  This could be because either a player is cheating or more hopefully just made a mistake.
Its impossible to give a definitely answer about what happens in this game as its not covered in rules.  What I would suggest is to if possible just apply the hand limit as soon as error is noticed.  If this would give a player an unfair advantage then maybe discard at random although that could be unfair.   The links above say the came has a quick start guide?  I assume this mentions the order to do things on a turn including the hand limit?  Many games come with something like this and its a good idea to use it to follow you turn.  Say out loud to other players that you are discarding help each other and remind each other of rules mistakes happen less often.
Comment: All players helping each other monitor rules and hand limits in all games and finding a way to carry on as best they can is probably the best option for all games.  Mistakes do happen and the best thing is just to find away to carry on that wont break a game.
Comment: I also couldn't find anything in the offical game rules or starter guide. It could be that the player is cheating or has honestly forgot. Therefore I feel the other players should keep a check. When caught the play should discard as per the rules. If one full round goes by and he is caught at the END of his next turn (when someone is just reviewing what all he played etc) then there's is anything one can do, and resume normally.

Monopoly Deal Discarding Extra Cards


Can a US pilot residing in the EU fly N-reg under IFR on a US PPL?

Question: I am a US citizen living in the Netherlands, and I have an FAA PPL(A) with current IR as well as an EASA PPL(A) without IR.  I am currently trying to figure out my easiest path to IR conversion, as I do not have the required 50 hrs PIC time to do a direct conversion.  I know I can do the CBIR, but I'm wondering if I'm permitted to fly N-reg aircraft under IFR in order to build the required hours.  I've heard that as an EU resident I'm required to fly using both an EASA PPL and FAA PPL in an N-reg, and therefore I assume the answer is technically no.  Am I correct in this assessment?
Comment: @StephenS Sometimes [FAA PIC time doesn't count for EASA purposes](https://aviation.stackexchange.com/q/22957/62), perhaps that's what happened here.
Comment: How did you get a FAA IR without 50 PIC? FAR 61.65(g)?
Comment: @StephenS By 50h PIC I mean 50h non-dual PIC under an IFR flight plan, which is how EASA counts it.
Answer: Long story short, European residents apparently require an EASA license to operate a foreign aircraft, even if they also hold a foreign license from the country the aircraft is registered in.

European regulations are really difficult to pin down because implementation is delegated to member states, however it looks like as a resident in an EASA country you do need an EASA license to operate an N-registered aircraft based there. There are many online sources that say that, although they typically don't link to actual regulations. Several of them mention that you get a 12-month period to acquire the EASA license, during which you can still fly with your foreign license.
For example:
AOPA blog article:

The European Aviation Safety Agency, a pan-European regulator, had
passed a regulation some years earlier requiring that European
residents acquire a European equivalent license to fly an N-registered
aircraft in Europe. This requirement didn't apply to nonresident
foreigners.

A UK Flight Examiner's website:

If your N-reg aircraft would be classified as an EASA aircraft if you
registered it under the G registration, AND it is based in the UK now,
you do need either an EASA licence to fly it or an EASA validation. If
you wanted to fly it outside the UK, you would need your FAA licences
too.

The underlying EASA regulation appears to be REGULATION (EC) No 216/2008, which says that it applies to foreign aircraft if the operator is based in Europe (Article 4, paragraph 1(c), emphasis mine):

registered in a third country and used by an operator for which any
Member State ensures oversight of operations or used into, within or
out of the Community by an operator established or residing in the
Community

Paragraph 2 says that the regulations apply to personnel too, it's not just about the aircraft itself:

[...] Personnel involved in the operations of aircraft referred to in
paragraph 1(b), (c) or (d) shall comply with this Regulation

The tricky part is that EASA leaves it to each member state to actually implement the regulations and sometimes they implement at different times (see comments in the AOPA article above). I couldn't find the Dutch regulations, but the UK regulations do confirm that only non-residents are exempt from European licensing requirements. Air Navigation Order, Article 149, emphasis mine:

This paragraph applies if the operator of the aircraft is neither
resident nor established in the European Union, and the person
acting as a member of the flight crew is the holder of an appropriate
licence granted or rendered valid under the law of the country in
which the aircraft is registered or the State of the operator.

(As an aside, the ANO article is written in a very confusing, double-negative construction, but it does line up with other sources.)
Because EASA delegates to each member state, the best way to get a definitive answer that applies to your situation is to contact the Dutch civil aviation authorities. When and if you do find out what the requirements are, it would be great if you would come back here and add your own answer to this question. There's surprisingly little definitive, sourced information available about this and a first-hand answer would be really helpful.
Comment: @rs_atl You're welcome. BTW, there's an FAA legal interpretation that you might want to see: [Condell, 2009](https://www.faa.gov/about/office_org/headquarters_offices/agc/practice_areas/regulations/interpretations/data/interps/2009/condell%20-%20(2009)%20legal%20interpretation.pdf). It says that even if you get a Dutch license it's only valid in the Netherlands as far as the FAA is concerned. If you fly an N-reg aircraft to France (for example), France would allow that with your Dutch license but the FAA wouldn't. That means you have to be legal and current per FAA regulations too.
Comment: Thanks, and you've basically summarized what I thought I knew, but couldn't find anything definitive on.  I wasn't sure if there was some sort of exception for US citizens, for example, but haven't seen anything.  I've found people here have conflicting understandings of the FAA/EASA rules, including around conversion of licenses, and both the rules and enforcement seem in flux and inconsistent.


What do you lose if you decide to play offline-only?

Question: I'm wondering what in-game experience you may lose if you decide to play offline-only in Dark Souls 2. Of course you can't invade or be invaded or request for help but I'm more concerned about the story / NPC / secrets. Do you lose something by playing offline?
Comment: There are a couple covenants which rely on you playing online to advance in them (which gives you items), but I think that's it.
Answer: I haven't discovered every last secret in the game, so I can't claim to be authoritative, but based on what I've experienced in this game so far and from my experience with prior games in the series:

You can't participate in any kind of co-op or PvP, obviously.
You can't read or write messages.
You can't meaningfully participate in (or earn rewards from) any convenants that require PvP or co-op interaction to do so.
Certain boss fights or protected areas that are designed to bring in other human players as opponents will probably use AI-controlled NPCs in those players' place.
All of the story/NPC elements are almost certainly still accessible, as NPC progress is solely based on your solo exploration and interactions, which are mechanically unchanged in offline mode. This is also how it worked in both previous Souls games.

The sole exception to this may be any covenant NPC dialog or events that are only accessible after you've ranked up in one of the aforementioned co-op or PvP-oriented covenants.
Answer: The answer above basically sums up the consequences of offline play. However, although your in-game experience will be different and you will be losing out on multiplayer related activities, playing offline should give you a much greater sense of satisfaction and instill into you a greater sense of excitement. The reason being is that the game is MUCH harder if you play offline. In Dark Souls II, the pvp is generally concentrated in certain areas and thus, you are mostly able to co-op with other people without consequence. By co-oping with other people, you are able to net experience by traversing throughout another person's area as a white phantom (there is no consequence upon death), reverse the consequences of death in your own world by helping other people as a white phantom, get help with your own area bosses, and are able to level up extremely fast by farming bosses. Generally, by playing offline, you will be able to truly appreciate the Dark Souls series for its difficulty and feelings of hopelessness, despair, and desolation. In the end, what I mean to say is that you need to limit co-oping to truly experience the greatness of the Dark Souls.
Comment: Reviving by playing co-op as a white phantom is just a bug and will probably be fixed in the future. Other than that I completely agree, it's much harder and satisfying if you play it alone.
Answer: I'm not exactly sure how accurate it is to say you can't rank up offline...I hit Lvl3 offline in Bellkeeper's off the Mad Warrior NPC spawn alone (which is EXACTLY why that NPC exists) & in NG+ it's a fact you can get Sunlight Medals off the Falconer enemies that start showing up in NG+ & beyond. I've also heard that killing Red Phantoms (I THINK it was) count towards Blood/Sentinel/Blue rankings, though I've not confirmed, plus you can get Invader-relevant tokens/kills through announced invaders (such as Bowman Gumfry/Doors of Pharros) & farm them quite effectively as the invaders respawn in NG+ (12x just like regular enemies). Point being I REALLY wouldn't be surprised if there was a way to Rank up EVERY Covenant offline...it'll likely just take longer (looking at YOU, Dragon Remnants)~
P.S.
If you are simply seeking to Plat/100% the game's Trophies/Achievements & are concerned about ranking for the couple spells that SEEM only available via ranking as a Blood/Sentinel (Chaos Firestorm, etc) & think 500 sucks as a number, Wellager sells them once you find him in NG++ (in case you didn't know)...hope that was useful info in any way~


Adding a new entry into a list of maps?

Question: How do I add a new entry into this Phonebook program? This is what I have so far. Any tip or help would be great.
void enterNewEntry(std::map<std::string, std::list<PhoneEntry>*> & phoneInfo) {

    string  firstName;
    string  lastName;
    string  phoneNumStr;
    priority_t  priorityVal;

    enterFirstAndLastNames(firstName, lastName);
    enterPhoneNumStr(phoneNumStr);
    enterPriorityNum(priorityVal);
}

Answer: this code snippet doesn't provide info about PhoneEntry class, neither map key,
but still:
auto someList = new std::list<PhoneEntry>(); //creating empty list
someList->insert(phoneEntryObject);          //fill list with data
phoneInfo[someName] = someList;              //insert pair - key(someName) with mapped data(someList) into map container

don't forget to manually free memory, even when you want to just erase element
Would suggest you to take a look at std::multimap STL container.

Adding a new entry into a list of maps?


Zero results in Query/GqlQuery

Question: How do I know if the results of my query either using the Query interface or the GqlQuery interface returned zero results? Would using .get() on zero results produce an error? If yes, what's the best way to handle it?
Answer: when doing a get() if there are no results you will have an object containing None
I normally do
result = query.get()
if result is None:
  #do the following

or if you want to check that its not none then
if result is not None:
  #do the following

Answer: if a query returns no results, fetch() returns an empty list [] and get() returns None
in either case you can use the following:
if result:
    #handle the result
else:
    #no results were returned

Zero results in Query/GqlQuery


How does the symbolism of carpentery and handling the dead bodies make sense in the Irishman?

Question: I got the point of painting the house as a symbol to kill someone because when you shot someone in the head and he is in front of wall, wall will get painted with the blood. But how is doing "your own carpentry" relate to handling the dead bodies. For recap, this dialogue came up when Frank talked to Jimmy for the first time about how he is a "painter" and do his own "carpentry"?
Comment: I don't think you should read too much into it. Firstly, this may not be completely accurate -- films about organized crime are inaccurate since the actual criminals tend to not want to reveal things. Secondly, related to the first, mob guys always spoke obscurely in case they were being recorded. They used nicknames for associates for this reason and it makes sense that they would also use code words for different crimes. But they were not writers concerned with symbolism -- many were functionally illiterate.
Comment: @releseabe This isn't about real criminals, this is a question about a work of fiction that was written by people who aren't illiterate and are known to occasionally employ symbolism.
Comment: @Cubic the movie was based on fact -- the phrase about house painting is the title of the supposedly factual bio of a real person.
Answer: If "painters" paint with blood, then the same line of thinking would suggest that "carpenters" put people in wooden boxes, i.e. handle and dispose of dead bodies.
Comment: Until the book which I saw when it first came out, I had never heard this term before. (In any other book or movie -- for example, despite the murders in The Godfather or Goodfellas, it does not come up and I also read Fratiano's bio where many murders occur and the term is not used.) I wonder if this term was invented by Frank S. He does not seem like a guy who would coin a euphemism but it is a fairly obvious euphemism if your MO is shooting people inside of houses.


Free software for calculating the net charge of an amino acid as a function of pH?

Question: Does a free software for calculating the net charge of amino acids as a function of pH exist?
Answer: I like MarvinSketch. You can run it in your browser or on your computer. Under Insert > Template, you can find all the amino acids. Once you've inserted one, select Calculations > Protonation > Isoelectric point and click OK. You'll get a window that looks like this showing the net charge versus pH (I picked a pretty boring one, but other amino acids produce more complex curves):
Comment: Needs Java. Thats a bummer. :(
Answer: I came accidentally across this old not fully answered question. Recently I wrote a web application mainly for the calculation of physico-chemical property of proteins (Prot pi). But you can also use this tool to calculate/estimate the titration curve of single amino acids. You can enter the single letter code for your amino acid (e.g. k for Lysine):

And there you get the net charge in function of the pH:


Does having a NI number mean exercising treaty rights?

Question: Does having a NI number satisfy the exercising of treaty rights for the purpose of EEA visas in the United Kingdom?
Comment: An NIN is neither necessary nor sufficient to establish that someone is exercising treaty rights.  But what is the actual problem here?  It's not usually necessary to prove the exercise of treaty rights to get an EEA family permit.
Comment: Assuming you mean **National Insurance number**, it would mean you are registered with the UK National Health system.
Comment: Yes National Insurance number
Comment: really it is not important for Eea fm and residence card ?
Comment: for EUSS FP and then pre settled status
Answer: An NIN may or may not be important for an EEA family permit or a residence card, depending on the circumstances.  In any any event, an NIN does not show that the person with the NIN is exercising treaty rights.  For example, someone could have an NIN and then move outside the UK.  They still have the NIN, but they're not exercising treaty rights.
Similarly, someone could be exercising treaty rights without having an NIN.  For example, someone who has just moved to the UK but hasn't yet applied for an NIN is nonetheless exercising treaty rights.
So, the answer to your question

Does having a NI number satisfy the exercising of treaty rights for the purpose of EEA visas in the United Kingdom?

... is no.
However, UK authorities can use the NIN to find information about the person's presence in the UK, so they ask for the NIN to make it easier to evaluate the application.


Auto Responder for custom Web to Case

Question: We recently put together a small APEX Controller with VF page to act as a Web-to-Case form.  It's running on a VF Site, and embedded in an iframe into our main website.  This was done to allow users to create a Case and upload files (as ContentDocuments with Links to the Case).
At this point, the Case is being created and the file uploads handled.  However, there are no auto-response emails sent.  Apparently there is a configuration our admins tweaked to send a "case received" email when a case is created.  The standard Web2Case setup triggered these (but of course doesn't allow file uploads).
I think the relevant code is:
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.AssignmentRuleHeader.useDefaultRule = true;
dmlOpts.EmailHeader.triggerAutoResponseEmail = true;
if (emailIsContact) {
    dmlOpts.EmailHeader.triggerOtherEmail = true;
}
WebCase.setOptions(dmlOpts);
//..
INSERT WebCase;

We're checking if the entered email is on a Contact record, and if so then a) that contact is associated with the case, and b) it's flagged and we set the triggerOtherEmail flag (setting this for emails of non-contacts seems to be a problem).
However, we're not seeing any auto-response emails go out (we've used several test contact of internal users).
Answer: The sobject.setOptions method seems a bit flaky (I've been meaning to ask someone about that). Try using the Database.insert(record, options) method instead:
Database.insert(WebCase, dmlOpts);

Comment: It took a while to get our admin to try out the new code.  Unfortunately it's seeming to function the same as before.  At this point I really suspect something possibly related to permissions for the anon Sites user.
Comment: @Robert Odd. Time to dig through some debug logs, it sounds like.

Auto Responder for custom Web to Case


Proper use of classes

Question: I'm writing a class that draws a very complex image, with multiple parts. I also plan on adding to the class to add more functionality. Would it be right to make a function for each part, even if that function will only EVER be called in the render function? I see an upside to this since it will be easier to read the code, and easier to add parts. A downside however, would be that it would increase complexity and quite possibly make it harder to maintain. Should I keep all the code in the render function, or break apart the different steps?
Comment: I guess your post title needs to change. Also, what you are describing here is encouraged by "Structured Programming".
Answer: Nope, breaking down complex methods into a sequence of smaller, private methods is perfectly good design and improves maintainability, if the new methods have descriptive names.
Comment: @LordZardeck: something like that. But thinking in "steps" too much smacks of procedural design. It would be better to have parts of the image that know how to paint themselves and also contain the necessary data. Or perhaps factor out computation tasks that are not directly related to painting.
Comment: That's what I figured. I just thought maybe if I end up getting so many "steps" that maybe it would get out of hand.
Comment: @LordZardeck: sure, every good thing can be overdone. If the number of steps really gets too large despite each one being non-trivial, that's an indication that you should try to break up the whole class into several parts with separate, mostly self-contained responsibilities.
Comment: So possibly breaking each step into it's own "step" class? Then having the original class build the steps?
Comment: @LordZardeck Data. Classes are also a lot about data. If you have some piece of code, where the data for the operation and the operations themselves can be self-contained, then it is a good candidate for a separate class.
Answer: Definitely break it up!  Break your steps into logical parts.  This makes the code much easier to troubleshot, especially when you are employing unit tests, which itself will save you loads of troubleshooting time in the long run.
Answer: Implementing small parts of an algorithm in separate methods that are all called from a "controlling" method, your render method, is an example of using the Template Method Pattern. It is an appropriate way to manage the complexity in your scenario.
As you decide how to refactor functionality into smaller methods, you will want to consider how to support your planned modifications while adhering to the Open-Closed Principle.  That is, try to break the methods down in ways that you can implement your changes by overriding individual methods in subclasses.

Proper use of classes


Definition of 1 calorie

Question: Why has the definition of  1 calorie been taken to be the energy required to heat 1 gram of water from 14.5 to 15.5 degree centigrade at standard pressure? Is there any specific reason for taking the temperature from 14.5 to 15.5?
Comment: Are you asking why some specific range was chosen, or are you asking why the starting point of 14.5 was chosen for the specific range?
Comment: There are several definitions of calorie. See [wiki](http://en.wikipedia.org/wiki/Calorie#Definitions) page.
Comment: I suspect this belongs on hsm.stackexchange ... our sister site for "history of science and math".
Comment: Pretty sure he's asking why the starting point is 14.5 degrees centigrade. As far as I know, no reason. I've always learned that it was the energy required to warm 1 gram of water by $1^{\circ}C$.
Answer: The reason for defining a specific starting point is to remove any doubt of how much energy 1 calorie is. You can just say that it is the energy required to warm 1 gram of water by 1 degree, but that is a different value depending on if you are referring to ice, liquid water, or steam. Even within the same state there are slight differences due to changes in density, etc. as illustrated by the wiki page in the comments. Even worse, the value of 1 calorie could be many times its usual value if you measured it as the amount of energy to raise water from 95.5 degrees Celsius up to 100.5 degrees due to the latent heat of vaporization.
As for why the specific 14.5 starting point was chosen, there may be some historical reason, but there is not function reason beyond just to make sure everyone is actually using the same unit. With all this confusion, it's no surprise that the Joule has become by far the favored unit in modern studies!
Comment: That's one nice thing about water though, the different states have their own names. In my experience, when someone says "water" it is assumed they are referring to liquid $H_2O$ unless otherwise stated. Anyway, you make some good points. +1!

Definition of 1 calorie


70mph in 2nd gear in automatic trans. Honda pilot

Question: My boyfriend drove me to dr. Yesterday at 70mph with my Honda Pilot in 2 nd gear. Did he damage my car?
Comment: Welcome to Motor Vehicle Maintenance & Repair!
Comment: Was it just for a brief period, at that speed in second gear?  Had he selected 2nd by mistake?
Answer: Probably not since most modern cars have rev limiters in the ECU.  This prevents over-revving the engine and causing damage.
You may want to consider upgrading your boyfriend, though.
Comment: That's what Suze Orman says about literally every relationship LOL.
Answer: If there were any real damage, you would know right away.  Listen carefully for any unusual whirring sounds, hard shifting, etc. during normal usage.
You might consider having the transmission fluid changed at a shop.  Running the transmission at a sustained, high rate could easily overheat and sheer the fluid.  Worn fluid will cause damage to internal metal parts before long.  A servicing costs about $125 for your vehicle and would be well worth the effort.


What aspects of macroeconomics should I address for convincing an investor to invest in a certain country?

Question: I have a task at my internship which is to write 2 pages about the economic conditions in my country. My question is what I could include in my research. Surely, I'll address inflation, currency fluctuations since they are very unstabe. What else can I add? Where can I get reports on a certain country, in this case is Egypt.
Comment: Supranational bodies like the IMF would be a good place to start, or the central bank.
Comment: Key risk factors? Political risk? Corporate governance risk? Valuation (eg. P/E type stuff)? Correlation with other markets?
Answer: As Brian said, international organisations are a good place to start. For example, the World Bank publishes periodic economic outlook updates on each country. For Egypt, see here. There is a pdf link to the right of the page. They covers aspects like GDP growth, inflation, financial and fiscal accounts, and also some prospects on ongoing, pro-business reforms.
Another source is the African Economic Outlook reports. Here is the one for Egypt. This is a bit more broad, including analysis of debt, revenues and spending, monetary policy, governance, natural resources management, and the social sphere (poverty, social protection, gender equality). See also the website of the IMF dedicated to Egypt.
Finally, having worked in the financial sector for a few years, I know that most of the investment banks produce periodic reports on every country their clients might have investment interests, reports that usually include a lot of forecasts. Albeit most of these reports are not available to the public, some googling still yield some results. For example, here is a very comprehensive analysis for Egypt from Deutsche Bank, published two months ago.  Other asset management companies also produce such reports (e.g here).


desktop wallpaper is upside down in lubuntu

Question: Having used ubuntu for over 3 years, I switched to lubuntu today. I downloaded a photo from gmail inbox and it saved in the downloads folder. When I set it as wallpaper it appears upside down. I have tried it with a couple of other photos but no change. The standard lubuntu ones are fine. Has anyone got any ideas as there seems to be no option to change it?   Many thanks, Ian.
Comment: what happens, if the image you'll set up as your wallpaper is added by you upside down? maybe a temporarily fix for the moment, if it works?! Also you could replace on of the original wallpapers with your own, leaving the original filename name, resolution and file ending intact, to see if that work, until there is a better solution (if it works at all)
Answer: My thought after hearing this is that the pictures that you are trying to set as desktop wallpaper contain some EXIF data that define their orientation.
While the photo ought to have been taken upside down, the EXIF data (that the camera included in the photo) inform your system that the picture was taken this way, and thus it displays the picture as it should be. This should be true for the file manager and for the picture viewer, in your case, but not for the application drawing your desktop.
My suggestion would be to open the picture in a program like Gimp, that will open it as is, and rotate it normally, then overwrite the original (or save it as a new image) and set it again as desktop background.
Comment: Thanks for the helpful answer. I had already found an option to turn off exif in the image viewer preferences, but the pictures i downloaded were before that. I just downloaded another with exif off and it's fine. It's nice to see my 2 boys the right way up! Thanks.
Comment: Thanks, if this answer actually solved your problem, please mark it as accepted.


Template option not coming for a new user even access to user for template is provided

Question: Template option is not coming for a new user even access to user for template is provided. I have created a new user and provide sitecore/developer role to it and in security editor manually provide all the access for template but still no template options is coming when i am logging in as new user.
Comment: What are the options for other users? Are they configured on Standard Values?
Comment: With on Sitecore/Developer role, you can get access to the template via desktop. So, instead of clicking on content editor from launchpad, click on the Desktop icon. Now, from desktop, click on Sitecore menu (red button at the left bottom). You'll see the template manager from the menu.
Comment: Is there any role through which i can directly give access of templates to user from content editor
Answer: If you have added proper role to the user or provided access directly to the user and still the templates not coming in the content editor then check the View option in the menu, You suppose to select both "Hidden Items" and "Entire Tree".
Mostly these will be unchecked for the newly created users.


Is there any possibility that UN could deprive the Russian Federation of the veto power?

Question: Is there any possibility that UN could deprive the Russian Federation of the veto power?
Because of what happened at one of the last UN sessions, I think that Russia was misusing its veto right (and it was not the first time) and the world peace was threatened.
Comment: I would strongly oppose depriving Russia of veto.It would make west free to make international policies against countries like India.I can not forget that it was Russia who protected India from international western military attack in 1971(by using veto and sending it's warships towards India).
Comment: I'm not sure how this can be answered outside of just offering an opinion. I mean, the obvious answer is still 'no', because you don't want Russia withdrawing from the UN, but still.
Comment: Very strongly doubt it, but I'll wait for someone else to write you a proper answer.
Comment: @Aditya Patil can you give link to the description of this episode?
Comment: @lowtech Read [foriegn involvement in 1971 war](http://en.wikipedia.org/wiki/Indo-Pakistani_War_of_1971#Foreign_reaction_and_involvement) and [how russia sank nixon's gunboat diplomacy](http://indrus.in/articles/2011/12/20/1971_war_how_russia_sank_nixons_gunboat_diplomacy_14041.html) and [role of Russia, china, US, britain in 1971 war](http://www.theworldreporter.com/2011/10/1971-india-pakistan-war-role-of-russia.html)
Comment: Well they missed their chance in 1990. Failing to recognize Russia as the successor state of USSR would have done it. (Legal backing: each of the members of USSR pulled out except for Georiga.) But I'm pretty sure that can't be done now.
Comment: related: [How did Russia retain the UNSC veto power of the Soviet Union?](https://politics.stackexchange.com/q/31767/16047)
Answer: The answer is No, since Russia is one of the five permanent members of the Security Council. All permanent members have a veto right, and they can any substantive resolution by the Council. The word "permanent" is clear enough that Russia always remains in that position.
You are not the first to ask the question since many members of the United Nations have asked this question in different forms. It is also clear the members of the United Nations have tried to reform the Security Council, mostly because the geopolitics has totally changed since 1945, and the Security Council has changed very little (an increase of the non-permanent membership from six to 10 members). The reform discussions about restructuring the composition in 1990s. In that time, Japan, Germany, Brazil and India wanted permanent seats. Later this group of four countries formed an interest group known as the G4. There were other countries who formed another interest group known as the "Coffee Club" and later "Uniting for Consensus" Italy, Spain, Argentina, Canada, Mexico, South Korea and Pakistan who were opposed to the G4 becoming permanent members with a veto power. They favored the expansion of the non-permanent category of seats with members to be elected on a regional basis. African group was demanding two permanent seats for themselves, and they believed that they can rotate the seats between African countries chosen by the African group. Each of the five permanent members had different reactions. The United States supported the permanent membership of Japan and India and a small number of additional non-permanent members. The United Kingdom and France supported the G4 position, with the expansion of permanent and non-permanent members and the accession of Germany, Brazil, India and Japan to permanent member status, as well as an increase the presence by African countries on the Council. China supported the representation of developing countries, and permanent membership of India.
A task force was shaped by the General Assembly to prepare a report for reforming the Security Council (the report on the question of equitable representation on and increase in the membership of the Security Council) and they tried to find a solution for starting negotiations on reform.
It is important to add that Kofi Annan prepared a plan entitled "In Larger Freedom" in 2005 and proposed two alternatives. A conference in that year studied the proposals. Nothing has been decided yet.
There have been discussions on limiting the use of the veto to vital national security issues or requiring agreement from multiple states before exercising the veto or even  abolishing the veto entirely. However, any reform of the veto will be very difficult. Articles 108 and 109 of the United Nations Charter grant the five members a veto over any amendments to the Charter, requiring them to approve of any modifications to the veto power that they themselves hold.
Comment: Eight years later this question is being revisited
Comment: It's blatantly incorrect that a permanent member cannot be removed from the UNSC.  Taiwan was a founding member of the UN and a permanent member of the council.  It was removed from the council by being removed from the UN.  So not only does such procedure exist in theory, but there is actual precedent for it.
Answer: There's no such thing as misuse of the veto right in the Security Council. It is working exactly as it is supposed to be. Each of the major power has reserved the right to solely block any resolution because of any reason, independent of the other members. This is how the veto works! It assures that UN is unable to take any action agains any interest of the major power without her agreement.
There's no way to take veto right away from the party, except the party agrees with it (which is unlikely) or creating a new organization, without that party. Technically, it could mean expanding NATO to the whole world, which is very unlikely in current geopolitical situation.
The UN remains the highest forum of the international community, even if it's unable to take any action in any case where the major power is involved. Please note also, that if any nuclear power remains outside the international community, it's the major threat to the international security. Even if the whole world would be against Russia, she will still have enough nuclear weapons to destroy the whole world.
Answer: On its own, the UN is a toothless organisation incapable of enforcing any of its numerous resolutions. However given the support of the world's most powerful nations, the UN becomes an important organisation who's decisions are at least somewhat respected around the world. And as it happens, Russia remains one of the world's most powerful nations thanks to its gigantic stockpile of nuclear weapons, capable of destroying all of the world's capitals several times over.
Hence removing Russia from the Security Council would be absolutely useless. Yes, you could now pass numerous resolutions that would otherwise have been vetoed by Russia, but this comes at a cost of Russia being free to completely ignore all of these resolutions at will. And you've now antagonised the country controlling the world's second large nuclear supply, further increasing the risk of World War 3. And China would likewise be antagonised by such a decision as it would rightfully suspect they're on the line to be eliminated from the Security Council.
In short, its better to keep Russia at the negotiations table than to kick them out and weaken the UN.
Answer: In theory, Yes.  But it would not be through a regular procedure.  Taiwan was a founding member of the UN and a permanent member of the UN Security Council.  It was thrown out of the UN and its place was taken by the PRC.  This was essentially done by challenging the notion that Taiwan was in fact China.
If there were competing claims over which government is the "real" government of the country currently known as the Russian Federation, the general assembly would have to take up that claim and it could eject the RF with 2/3 of the vote (as it did with Taiwan).  This would not require the Security Council's approval.
There is another possibility, but I am not sure about how (or even if) it would work procedurally.  From the UN's standpoint, all 15 states which were created through the dissolution of the USSR were legally "successor" states to the USSR.  Putting all 15 states on the Security Council was not practical.  So through a series of negotiations, concessions, and decisions, only the Russian Federation was given the successor status.  Whether reversing such decisions is subject to Security Council's approval is not something that I know.  But if it isn't, then removing RF's status as a successor state of the USSR would leave USSR's Security Council seat vacant.


Should an author seek copyright clearance before finding a publisher?

Question: I would like to include some material which will need clearance. Is this something that needs doing before finding a publisher? Or is it just that one publisher talks to another, and authors have no business being involved in?
Answer: If you are using content that is protected under copyright, then you should make sure that you have permission to use it and/or have attributed the original source appropriately before trying to find a publisher. The act of trying to sell your own work which contains somebody else's copyrighted content could be construed as a violation of that copyright. It is highly unlikely that any publisher will even consider your work, let alone attempt to pursue the permission or release from the original source.
When I say "and/or" have it attributed, I mean to say that you may be able to use the copyrighted material with only an attribution to the creator of the material, and not explicit permission. This would ultimately depend on how you are using the content and how much of it you are using. If it falls within the guidelines of Fair Use, then all you need to do is give credit to the original source. (The link will provide some detailed examples.) If your usage of the copyrighted material goes beyond this, then you will need to seek permission and give credit to the original source.

Fair use is a limitation and exception to the exclusive right granted by copyright law to the author of a creative work. In United States copyright law, fair use is a doctrine that permits limited use of copyrighted material without acquiring permission from the rights holders.
Comment: The and/or makes a huge difference. Are you saying that seeking publication with copyrighted material acknowledged but no permission yet approved is a no-no? I'm just imagining that publishers really wouldn't want to deal with formal requests by unpublished authors.
Comment: I will edit my answer to further explain why I used "and/or".


Connect iPad 5th Gen to Keyboard

Question: I have a Yamaha PSR i455 keyboard and I'd like to connect it to my iPad so I can play the yamaha to input the MIDI data into Garageband. I have an aux cord (3mm jack on both sides) but its too small for the keyboard port. I've seen 3mm to 6mm adaptors on Amazon but I'd like to know if it'll allow me to connect to garageband. I've been able to connect and input midi to my laptop through the printer cable, but I'd like to be able to connect it to my iPad too.
Comment: Hi docwho029. One of the criteria on this site for questions is that they show some effort at solving the problem yourself. A simple Google search for "piano to ipad" finds many results that may provide the answer you need. If you've already tried that, please indicate it in your question with some comments on why those answers didn't work.
Comment: Just that you know, some older Yamaha keyboards use non-standard USB MIDI protocol. There's a driver to use them on Windows and Mac, but not iOS.
Comment: Oh, I'm sorry. I thought I'd get more general answers if I left my question vague. Should I make a new post or edit this one?
Comment: As far as my earlier comment goes, your recent edit is perfect. No need to open a separate question.
Answer: The "Lightning to USB Camera Adapter" can be used as a USB/MIDI input. I verified it works with Garage Band on the iPad Mini (5th generation, circa 2019 and first generation, circa 2012).
Comment: Oh, thanks! Do you know if the headphone jack will work as a line in for MIDI data? The lightning to USB adaptors i saw on amazon are a little over my budget, so I was looking for a way to use an aux cord(3mm on both sides) which connects the headphone jack of the iPad to a cheap 6mm adaptor which connects to the keyboard?
Comment: @docwho029 One important point: MIDI is computer data, not analog audio data. You can't use an audio jack to transmit MIDI. (Also, you're trying to get data _out_ of the keyboard and _into_ the iPad.) You'll need to use the USB out of the keyboard, and you'll need a cable that connects that to the lightning (data) input of the iPad.
Comment: Chances are you already have a USB-to-lightning cable; it's probably what you use to charge the tablet. If you don't, they shouldn't cost more than about $30USD (often much less).
Comment: the cable doesn't work because my keyboard has a USB-B as MIDI out, and the standard USB port is just for flash drives and importing styles and instruments to the keybiard, and not for exporting MIDI. I guess I'll just buy the lightning to USB adaptor and use my USB-B to Standard USB cable to connect the two devices. Thanks!

Connect iPad 5th Gen to Keyboard


How to calculate the pressure applied in a compressible fluid?

Question: If I am trying to figure the pressure needed contain a fluid like hydrogen in a cylindrical tank, how would calculating this go on? As Hydrogen is compressible to a differing amount than other compounds and has a volume, doing a force over area is un-feasible. Hence, what formula or steps are needed to compute this?
Comment: Are you just trying to calculate pressure of a mass of hydrogen?
Comment: What is the starting state of your hydrogen in terms of temperature, pressure, and mass (or volume)? What is your desired end state for the hydrogen? As a general note, if you aren't familiar with the hazards of working with hydrogen you should familiarize yourself with them before working with the gas.
Comment: I am trying to figure out the force required for a piston to compress a certain volume X of hydrogen with two piston's, and by result, the displacement of the piston's. This is just a theoretical investigation, no device will be built.
Answer: You need to find the compressibility factor, which is defined as $Z = \dfrac{pV}{nRT}$ of the hydrogen, then correlate to the "ideal gas", which has a compressibility factor of 1.
https://en.wikipedia.org/wiki/Compressibility_factor
Comment: Thank you. That will allow me to calculate the compressibility, yet how would I use that value to compute the pressure and by proxy needed to compress a specific volume of hydrogen with a piston?
Comment: The molar volume of the ideal gas, V_ig = RT/p, and the corresponding molar volume of the real gas, V_rg = RTZ/p. Does this help?
Answer: Hydrogen will not liquify no matter how high it is compressed. Unless it is cooled down to its critical temperature which is $ - 252.8^{\circ}C$

Hydrogen can be physically stored as either a gas or a liquid. Storage as a gas typically requires high-pressure tanks (5000–10,000 psi tank pressure). Storage of hydrogen as a liquid requires cryogenic temperatures because the boiling point of hydrogen at one-atmosphere pressure is -252.8°C.

That means theoretically if you can maintain the hydrogen below critical temperature the vessel vapor pressure is about one Atm.
Hydrogen can be stored on the surface of solids by adsorption and in the solids by absorption.
.

Quote from source


Is there intuition behind asymmetry in call and put prices?

Question: There is a certain asymmetry in (European) call/put prices, even with negligible interest and dividend rates. For example, assume current price $100, interest rate 0.01%, dividend 0, volatility 25%, expiration 3 months. According to BS model, 110 Call is $1.68 while 90 Put is $1.31. Why are they different? Cost of carry is negligible, ΔS/S is the same in both cases. I suspect it has to do with σ2t term and possibly lognormality of returns, but looking for more intuitive explanation ("explain to me like I am 6").
Comment: Are you talking about _actual_ market prices or _theoretical_ prices?
Comment: Also, puts and calls _should_ have different prices at the _same_ strike since calls get cheaper and puts get more expensive as the strike goes up. Do you mean for strikes in opposite directions, like say a $110 call and a $90 put?
Comment: I am talking about *theoretical* prices
Answer: The premium/price of a put option should be different than that of a call option.
Relative put and call prices differ by the riskless rate of interest. So when interest rates rise, a call's price rises and a put's price decreases. This is explained by the put-call parity.
"When European options are at the money and the stock pays no dividends call prices exceed put by the riskless rate of interest."
So when the interest rate is small and unchanged but volatility rises, the difference in premiums is expanded under the Black- Scholes model. Similarly if time to expiry changes the effect also causes a rise in premium prices.
Just a note if both assets are equivalent in every way then the call may be overpriced or the put is underpriced
Answer: DISCLAIMER: Any explanation  by me WILL sound like I am 6 years old :->)
Here's a passage from Natenberg's book : Option Volatility and Pricing Strategies:

The lognormal distribution of prices assumed in the Black-Scholes model helps explain why options with higher exercise prices seem to carry more value than options with lower exercise prices.  For example, suppose a certain commodity is at exactly 100.  If there are no interest considerations and we assume a normal distribution of possible commodity prices, then the 105 call and the 95 put, being equally far out of the money,  should have identical values.  In fact, under the assumptions of the Black-Scholes model the 105 call will always have a greater theoretical value.  The lognormal distribution allows for greater upside price movement than downside price movement in the underlying commodity.  Consequently the 105 call will have a greater possibility of price appreciation than the 95 put.  Of course, if one were to assume a normal distribution of prices, then both options would indeed have the same value.
Comment: Interestingly, if observed market prices for symmetric puts and calls are equal or similar, it should produce the volatility smile (puts vol is higher than calls vol)
Comment: If volatility is symmetrical but higher for OTM options, it's a volatility smile.  If it's asymmetric, it's a volatility smirk (skew).  More specifically, it's called reverse skew if put vol is higher than call vol and forward skew if call vol is higher than put vol.


How do I send a site user login information without being redirected to that site?

Question: I have a form that collects a user's username and password for a third-party site. Only when the login information works do I want to proceed on my site. My problem is that I currently have it set up as a form with the action link the third-party and when they click on the button, it just redirects them to the other site. How can I only test that the username and password succeeds on the page without sending them to the page? Is there a way with PHP?
Answer: Yes there is -> curl extension or http_post_data() ( or http_post_fields() part of pecl_http extension). There are examples too.
Depending on third-party site returned html/cookies/etc proceed the process or draw an error message.
Answer: Yes.  You have it post the login information to your page first.  Your page then curl's (or some other way of getting a remote page, such as http_post_data) that third party page, and checks of the login worked or not.  You may also then have to hit that third party page a second time, to log you out (if it preserves the login, that would be bad).
Anyway, after it returns, you can then process the page as a login success or failure.
Answer: This could be done with jQuery, avoiding any server-side complications. You could submit the form via the <code>.post</code> event, and read the response body to see if it was successful or not (they will probably have a success page, perhaps a user home page, or error page).


quantum optics of a polarizing beam splitter

Question: I would like to use the Heisenberg picture in quantum field theory to model a polarizing beam splitter.  Is there an easy way for someone to show me how the field operators ($a^\dagger_{input1}$, $a^\dagger_{input2}$etc) transform across a polarizing beam-splitter?
Comment: Leonhardt's [Quantum Physics of Simple Optical Instruments](http://arxiv.org/abs/quant-ph/0305007) may contain some useful information for you.
Answer: Much depends on how "deep" do you want the description to be. Let's assume the beam-splitter works as an external potential (in QM) and does the scattering. The 1-particle scattering operator is the unitary operator of the "Hadamard gate",
$u=\begin{pmatrix} 1& 1\\ 1& -1 \end{pmatrix}\frac{1}{\sqrt2}.$
This is generated in time $t=-\pi/4$ by the Hamiltonian $h=\sigma_2$ (2nd Pauli matrix). Promoting these to many-body by the rule $G=\sum_{ij} a^*_i \langle \psi_i|g\, \psi_j \rangle a_j $ (for some 1-particle operator $g$) you should get the many-particle Hamiltonian
$H=\frac{i}{\sqrt{2}}\left[a^*b -b^*a \right]$
which in the same time $t=-\pi/4$ should produce the unitary Beam-Splitter-transformation
$U=\frac{1}{\sqrt{2}}\left[(a^*+b^*)a+ (a^*-b^*)b \right]$
(here $a,b$ stand for $a_{input\ 1,2}$). The transformations of any many-particle operators can now be computed by the Heisenberg transformation $G(t)=exp(iHt)G(0)exp(-iHt)$.
If you wanted, however, to know about the interaction with some quantum model of the beam splitter, then it becomes more complicated (note, however, that no entanglement with the state of the beam splitter is apparently being produced in experiments, which is interesting in its own right).
Answer: This isn't terrible hard to do.
Say the PBS reflects vertical polarised light and transmits horizontal.
So we have a 4 mode system with the following transformation
$$\left[\begin{array}{c}
a^\dagger _{1H} \\
a^\dagger _{1V} \\
a^\dagger _{2H} \\
a^\dagger _{2V} \\
\end{array}\right]  \rightarrow \left[\begin{array}{cccc}
1 & 0 & 0 & 0 \\
0 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 \\
0 & 1 & 0 & 0
\end{array}\right]
\left[\begin{array}{c}
a^\dagger _{1H} \\
a^\dagger _{1V} \\
a^\dagger _{2H} \\
a^\dagger _{2V} \\
\end{array}\right]
$$
Notice this is like CNOT gate with the polarisation qubit controlling the path qubit.


Was Luke an eye-witness to the crucifixion?

Question: Is there any reference that Luke was at the crucifixion of Christ?  Or if he had met Jesus face to face?  Or was his account of Jesus' life written by research or listening to reliable sources such as Paul?
Comment: Luke reads more like research, or a second hand account. It does not read like a testimony, like John.
Answer: There are two issues here. The first one is that Luke is not mentioned as an eyewitness to the crucifixion and, being a companion to Paul in the fifties, more than twenty years later, was unlikely to have been an eyewitness. The second issue is that Luke the physician is unlikely to have been the author of the gospel that now bears his name.
Eyewitness to the crucifixion
Mark's Gospel tells us that the women who knew Jesus watched from afar off, with no mention of Luke, or of the disciples

Mark 15:40: There were also women looking on afar off: among whom was Mary Magdalene, and Mary the mother of James the less and of Joses, and Salome.

Matthew's Gospel (Matthew 27:55) agrees with Mark that only women watched from a distance. Luke's Gospel is more ambiguous, allowing that the little group might have included men, but with no mention of names (and certainly no mention of Luke):

Luke 23:49: And all his acquaintance, and the women that followed him from Galilee, stood afar off, beholding these things.

Composition of Luke's Gospel
All the New Testament Gospels were written anonymously. The Gospel now known as Luke's Gospel was attributed to Luke during the second century, apparently on the basis that it appeared to have been written by a gentile, and the same author wrote Acts of the Apostles, which was thought to point to a close acquaintance of Paul as the author.
'Luke' opens the gospel by assuring Theophilus of the veracity of his account. Presumably if he had been present in Jerusalem, or if he had researched the facts about Jesus, or even received his gospel knowledge from Paul, he would have said so, but he does not. If he had learnt it from a reliable witness to the the mission of Jesus, he would also have said so, at the same time declaring this to be clear evidence of the gospel's reliability. Instead, he merely says that the gospel came to him through prior sources, the first of whom was [presumably] an eyewitness:

Luke 1:2: Even as they delivered them unto us, which from the beginning were eyewitnesses, and ministers of the word;

It is the almost unanimous consensus of critical scholars that Mark's Gospel was one of Luke's sources, with a strong but less overwhelming consensus that the hypothetical 'Q' document was another of the sources to which he refers in the prologue. John Dominic Crossan says in The Birth of Christianity, page 93, that he spent the 1960s in a monastery, poring over the gospels in parallel columns, word after word and unit after unit, day after day and year after year, studying the scholarly hypothesis and doing source-criticism. In the end he found it absolutely convincing.
Comment: Mark's Gospel was *the primary* source for Luke's gospel. Alternatively, both Mark and Luke used the same primary source. I've also heard Q to refer generically to any other lesser sources, whether witness or parchment.
Comment: @fredsbend *Mark* was indeed the primary source for *Luke*. There are technical reasons that rule out *Mark* and *Luke* sharing another common source.
Comment: What sense does it make to say the Gospels were 'written anonymously'? If this is intended to mean their authorship was ever disputed or different than the perennial ascription to the respective authors, where is the evidence?


Tweepy Psycopg2 creating points, coordinate system SRID confusing

Question: I am using Tweepy and Psycopg2 to extract tweets and input them in a PostgreSQL table. When I try to insert the point of the tweet I succeed in creating a point in the geom column I create. I however do not succeed in getting a basemap aligned behind it, while I thought I had the tweets in SRID=4326 which is WGS84.
Is there something wrong with my script? I suppose the basemap is not wrong but I can't be sure.
cur.execute("SELECT AddGeometryColumn('public', 'test', 'geom', 4326, 'POINT', 2)")
cur.execute("INSERT INTO Test(geom) VALUES(ST_SetSRID(ST_MakePoint(%s,%s),4326))",(tweet.coordinates['coordinates'][0],tweet.coordinates['coordinates'][1]))
        con.commit()

Or are Tweepy points just not in WGS84? I thought they were.
*** update
This is my search statement
for tweet in tweepy.Cursor(api.search, q="*",since="2016-02-10", until="2016-02-29", count=100000, geocode="5.29126,52.132633,150km").items(10000000):

Expecting the tweets to be in the Netherlands and parts of Belgium and Germany.
I did make some steps getting tweets in Belgium on  the right location. But it's still weird. I load in a basemap in EPSG::3857 and then need to put the tweets on EPSG::4326 and they align. When I put them in the same CRS they do not align.
Comment: Can you give a sample of the tweet.coordinates parameter that you're having trouble with? Like you I'm pretty sure that the coordinates from twitter are simply WGS84 longitude/latitude. Also, are you using streaming or searching to get the tweets with coordinates?
Answer: I've created a plugin for QGIS called twitter2qgis which fetches data from twitter firehorse.
The coordinates in tweets are in EPSG:4326 if they are provided..
and the geocode must be in lat,lon,radius. Yours are in lon,tat,radius:
geocode="5.29126,52.132633,150km" --> geocode="52.132633,5.29126,150km"


Open an emacs file from terminal

Question: I want to open emacs + an emacs file directly in the terminal, the file in question, how should I go about it?
Comment: Why are you not satisfied with `emacs` followed by the file name?
Answer: Since you are using putty I assume you want a non-X version of Emacs:
emacs -nw test.txt

will open test.txt in a non-window version of Emacs.
If you need to open test.txt on a particular line and column use:
emacs -nw +5:8 test.txt

This will set your cursor to column 8 on line 5 (or at the end of that line if it is not long enough).
Comment: I would perhaps add that in some distros, there's a package called emacs-nox.  If you install it, then you can just type `emacs-nox file` or are even able switch permanently to non-X version via `alternatives --config emacs`.  Or perhaps `update-alternatives`, that really depends.
Comment: @MiroslavFranc You are right, and that is the case on my system (Ubuntu 12.04). At this point I was (am) however not even sure this answers the OPs questio.

Open an emacs file from terminal


Which version of turbo tax has "The cost basis is incorrect or missing on my 1099‑B" in TurboTax in the case of vested RSUs?

Question: The RSU cost basis is incorrect on my 1099-B' and it repost 0.  Before the stock was available to me and company sold some of my shares as tax deduction.
Comment: Your question is not very clear. Are you asking in what version of TT you can do adjustments to basis on schedule D?
Answer:
The RSU cost basis is incorrect on my 1099-B' and it repost 0.

That's not because of TurboTax, but instead  it's due to the way brokers report cost basis for RSUs:
Why is the cost basis reported by a broker on RSUs 0 USD?
See https://money.stackexchange.com/a/149724/5656 on how to report RSU cost basis properly.
Comment: I found the cost basis from eTrade, followed by someone posted in the following steps.  My problem is that I do not how to use TurboxTax to adjust, because it use 0 as cost basis
I tried option:  I have RSU,  and tried option my 1099-B has infor I know is not right ...

1. Go to https://us.etrade.com/etx/pxy/tax-center
2. Click on Stock Plan Transactions Supplement
3. Look at the Adjusted Cost Basis column


How to replace Nexus 5 battery?

Question: As we all know, the battery in the Nexus 5 is sealed inside the phone chassis and cannot be replaced by the owner the way other phones' batteries can be. I am not particularly in favor of disassembling the phone by myself and manually replacing the battery. The point is, say I use this device for a few years: sooner or later it will need a new battery as the old one wears out. So how do I replace it ? Is there a safe, convenient way to get this done without taking any risks with the device ?
Answer: There is a free guide available on ifixit.com:
https://www.ifixit.com/Guide/Nexus+5+Battery+Replacement/26009
Of course, when disassembling the phone you always take various risks of damaging it, but I assume you are aware of that.

How to replace Nexus 5 battery?


random number generator monkey test diehard

Question: I have a question about Diehard Testtool. My Random Number Generator doesn't passed monkey test (DNA Test).  One p-value was 0. Is this critical? How can I interpret the result?
Thank you in advance!
Answer: You can never be sure with random number generators. If one odd test gives a p value in one of the bitstreams as 0 or nearly 0 then it might not be a cause of worry but if u get most p values as 0 and till six decimal places then it needs further testing.


Check if lists contain same objects

Question: I have two filled lists.
The first list contains for example:
"Shoppinglist-fruit", "Shoppinglist-drinks", "Shoppinglist-dinner"

The second list contains:
"Shoppinglist-drinks"

Now i wanna print all items in the first list, except if there's a same object in the second list with the same name (Shoppinglist-drinks).
Looking like:
 "Shoppinglist-fruit", "Shoppinglist-dinner"
So how can i check if the name of the object inside the second list is also in one of the objects of the first list.
Eventually i want to end up with a string containing all the names of the shoppinglists that are in the first list and not in the second one.
I started with some code below but i haven't been able to finish it.
I have the two lists, one called listShoppinglists, this is a list filled with different shopping lists.
And the second list filled with somebody's shoppinglists.
So i wanna check if the name of the shoppinglists are equal.
If done that by doing so.
public String getAllShoppingLists(List listShoppinglists, Customer customer, List shoppinglists) {
String namesOfTheShoppingListNames = ""
for (Shoppinglist shoppinglist : listShoppinglists) {
       for (int i = 0; i < customer.shoppinglists.size(); i++) {
           if (customer.shoppinglists.get(i).getName().equals(shoppinglist.getName())) {
    // Some action here
           }
       }
    }
return namesOfTheShoppingListNames;
}

Comment: You seem to be conflating the list elements with one property (name) of those elements.  This is not helped by the fact that you are using raw types.  And in any case, it's not clear what you're actually asking.
Answer: You can try this:
    List<ShoopingList> firstShoppingListNames = new ArrayList<>();
    firstShoppingListNames.add(new ShoppingList("fruit"));
    firstShoppingListNames.add(new ShoppingList("dinner"));
    firstShoppingListNames.add(new ShoppingList("juice"));
    List<ShoppingList> secondShoppingListNames = new ArrayList<>();
    secondShoppingListNames.add(new ShoppingList("fruit"));

    List<ShoppingList> distinct = firstShoppingListNames.stream().
            filter( list -> secondShoppingListNames.stream().
            noneMatch(o -> o.getName().equals(list.getName()))).
            collect(Collectors.toList());

    distinct.forEach(o -> System.out.print(o.getName()));

In this case you are using stream to achieve what you want. You filter first list to obtain those elements, which are not present in other list.
Additionaly if you want to obtain only names of those lists you can use map:
    List<String> distinct = firstShoppingListNames.stream().
             filter( list -> secondShoppingListNames.stream().
             noneMatch(o -> o.getName().equals(list.getName()))).
             map(ShoppingList::getName).collect(Collectors.toList());

Answer: Use Collections.removeAll() method to do this. Quoted from JavaDoc:-

Removes all of this collection's elements that are also contained in
  the specified collection (optional operation). After this call
  returns, this collection will contain no elements in common with the
  specified collection

.List<String> list1=new ArrayList<String>();
        list1.add("Shoppinglist-fruit");list1.add("Shoppinglist-drinks");list1.add("Shoppinglist-dinner");
        List<String> list2=new ArrayList<String>();
        list2.add("Shoppinglist-drinks");
        list1.removeAll(list2);
        System.out.println(list1);

//Output:- [Shoppinglist-fruit, Shoppinglist-dinner]

In case, lists contains a custom objects, override equals and hashcode methods in that custom object.
Comment: I believe that overriding equals for one case which here is name of Shopping list is not good approach. In such cases we need to think about future problems which simple equals may cause.
Comment: @KamilBanaszczyk, If list contains custom objects, then your solution is anytime cleaner than what I suggested. But if they just contain Strings, removeAll is more than enough.

Check if lists contain same objects


Is this proof that intervals are connected correct?

Question: First of all, the definition of conectedness I'm using here is: let $A\subset \mathbb{R}$, a split of $A$ is a pair $(A_1,A_2)$ of open subsets of $\mathbb{R}$ such that $A\subset A_1\cup A_2$ and $A_1\cap A_2=\emptyset$. The split is said to be trivial if $A_1\cap A = \emptyset$ or $A_2\cap A = \emptyset$. The set $A$ is said to be connected if it admits just trivial splits.
Now, with this in mind, my proof that every interval is connected is as follows:
Let $I\subset \mathbb{R}$ be an interval and suppose $I$ is not connected. Then there is a non-trivial split $(A,B)$ of $I$. In that case there is $a\in A\cap I$ and $b\in B\cap I$ and since $A\cap B = \emptyset$ then certainly $a\neq b$. Without loss of generality suppose $a < b$. Since $A$ and $B$ are open the following sets are not empty
$$S_1 = \{\epsilon \in \mathbb{R} : (a-\epsilon,a+\epsilon) \subset A\}, \\ S_2 = \{\epsilon \in \mathbb{R} : (b-\epsilon,b+\epsilon)\subset B\}.$$
They are also both clearly bounded above by $|b-a|$. In that case there exists the numbers $\epsilon_1 = \sup S_1$ and $\epsilon_2 = \sup S_2$. It is also clear that $a + \epsilon_1 \leq b - \epsilon_2$. Because of that we can consider the midpoint
$$x = \dfrac{(a+\epsilon_1)+(b-\epsilon_2)}{2}.$$
This element is such that $a + \epsilon_1 \leq x \leq b-\epsilon_2$. But by definition of $\epsilon_1,\epsilon_2$ this means that $x\notin A$ and $x\notin B$ so that $x\notin A\cup B$. Now, $I\subset A\cup B$, hence $x\notin I$, and still, $a < x< b$ with $a,b\in I$, contradicting the fact that $I$ is an interval. In that case $I$ is connected.
I'm a little unsure of this proof becuase of the way I picked $\epsilon_1$ and $\epsilon_2$. Is the proof correct? Is something I've missed along the way?
Answer: Hint: your argument doesn't work, as you can see by taking $I = (0, 1)$, $A = (0, 1/4)$, $B = (1/4, 1)$, $a = 1/10$ and $b = 9/10$. You will get $\epsilon_1 = \epsilon_2 = 1/10$ and $x = 1/2 \in B$. This is because you are looking at intervals contained in $A$ (resp. $B$) that are symmetric around $a$ (resp. $b$). Instead, try assuming (without loss of generality) that $a < b$ and consider the supremum of the $\alpha$ such that  $(a, a + \alpha) \subseteq A$ and the supremum of the $\beta$ such that $(b - \beta, b) \subseteq B$.


should I buy an amplifier or monitor PA for my electro acoustic guitar?

Question: I have an Epiphone Masterbuilt, which has eSonic2™ preamp system, I was wondering if I should buy an amplifier or a monitor (PA system)... Thank you!
Comment: Welcome to the site. I've removed the "what brands are best" bit as we try to avoid evaluating specific brands/models - hope that's ok.
Comment: I play acoustic guitars with pickups in various situations.  When I do, I also sing so I need to be able to plug in my mic as well as guitar.  I sometimes use a full PA, sometimes use a powered monitor as a mini PA, and sometimes use my inexpensive Acoustic Amp that has two channels (one for instrument and one for mic) with separate controls for each.  I will post an answer later when I have more time to explain the advantages, disadvantages and potential uses for various solutions that I have personally used (and I have used tons of different systems).
Answer: It may depend what else you want to do, now, or ultimately. There's hardly a need for an amp of any sort for home playing and practising with an acoustic guitar, whether it has pups or not. So I assume it's for playing in public. Merely playing the guitar, perhaps with others, an amp will do the trick. Especially an acoustic guitar amp.
However, if you sing as well, you're going to need an amp for that - and a mic - and an acoustic amp won't be as good as a p.a, which will also do a good job with the guitar.
There are many amps out there over the last few years which have been specially produced to be used as mini p.as, and guitar amps all rolled into one. And they do extremely well at both. Not cheap, but quality rarely comes that way.
Not recommending any brand - it's not company policy - but one of those would be a best bet, if you need more than just a guitar amp.
Incidentally,(as you mention p.a/monitor); a p.a system in its simplest form comprises mic., mixer, amp and speaker/s. 'Monitors' are an extra, so that the performers can hear better on stage. You could get away with a powered monitor for smaller gigs, instead of a p.a.


Kirchoff's law finding the voltage across resistors

Question:
I've just started an engineering course, and my 1st module is electrical engineering. Unfortunately my teacher is a 100 years old and hasn't explained Kirchoff's law to us in an understanding manor. In this question I've been asked to find the voltage across each resistor. Please could someone explain to me how this is done. The simpler the explanation the better, I honestly won't find it patronising, it would be a great help.
Thanks in advance
Comment: Do you know how to solve the circuit if there was only voltage source present ?
Comment: Perhaps the teacher is excellent, and you are the opposite.
Comment: No textbook for the course ?
Comment: no i wouldn't know
Comment: FYI there are various on-line lectures that are more suitable than this site when you know nothing. Getting a nutshell response here won't be a good a substitute for that. Youtube is your friend Reasonable examples: https://www.youtube.com/watch?v=IRgZ-puZjfA&list=PL8kq5qsK0cc42p-m3eGHiuCi3Xr_ORv9W&index=1 and http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-002-circuits-and-electronics-spring-2007/video-lectures/ Good luck.
Comment: You can use Thevenins and nortons equivalent circuits here to check your answer
Answer: Kirchoff's laws don't all need to be used to solve one circuit. You can go with Kirchoff's nodal analysis (KCL), or Kirchoff's Voltage law (KVL)
Kirchoff's nodal analysis (KCL):
Sum of the currents going into a node equals the sum of the currents coming out.
So..
Let us assign a variable name to (i.e. Vx, Va) to any connection with more than 2 ends.
So assign Vx to that node on the top.
Then you need to characterize the algebra problem by defining each current and how they equal relative to each other using this law.
Then try to analyze the currents across each branch with respect to Va and to ground or voltage source that is in series.
Kirchoff's Voltage law (KVL):
Sum of voltages in a loop sum up to zero.
A loop in this context is a series of circuit components whose path starts at a source path and leads down back to the that source path, path = < c1, c2, c3, c1 > (where cx = component x) (i.e. 10V, 5Ohm, 10Ohm, back to 10V)
So.. assign all existing current loops,
i.e. left loop can be Current 1, I1
right loop can be current 2, I2
and the current going down between the two (current 3, I3) is a mix of the two, which relatively depends on the direction assigned to each current (I1, and I2)
Then you need to characterize the algebra problem to find the voltage across each component in each loop.
Answer: It's too bad that you do not have a great teacher. For me, I find that Kirchoff's laws are just amazing. And they really are quite simple. Just by using Ohm's Law (\$v = i \times R\$), and Kirchoff's laws you can solve any network that consists of passive components.
Kirchoff's Current Law
The easiest one to understand is the current law. Think about a "cut" through a wire. Since no current flows out of the wire into air, the amount of current into the cut, must be the same as the current out of the cut area. The same idea applies to a junction, so
$$ i_\text{in} = i_\text{out}, $$
simple as that.

A note about directions. Make a habit out of writing arrows for your currents. It doesn't matter which way you write them, because the cool thing about the equations is that if you guessed the wrong direction, the resulting current simply gets negative.
You may also have seen the law as $$ i_1 + \cdots + i_n = 0. $$ This assumes that the direction is either all into or out of the junction (the node). So, for instance for the equation above, \$i_\text{in} - i_\text{out} = 0\$ makes sense, since the current going into the cut on the output side must be the negated current out of the cut.
Voltage levels in a circuit are relative. In order for you to measure voltage, you need two leads. To make things simpler, we usually define a specific node which we consider 0V, which we call ground. It usually makes sense to attribute ground to the negative battery connection, because then most other nodes will be positive (compared to ground).

Using KCL
I will solve your problem using KCL and Ohm's Law. You have two junctions, the top one and the bottom one. I will call the bottom one ground, since it is connected to both negative battery terminals. So we define the voltage level there to be 0V.
There are two other nodes, the connection between the left battery (\$+\$-terminal) and the \$5\Omega\$ resistor, and the right battery and the \$6\Omega\$ resistor. We know the voltages of those because of the batteries (10 V and 12 V).
So, we are left with a single voltage, the top junction, which I will call \$V_x\$.
We see that the voltage drop from the left battery over the left resistor is \$10 - V_x\$. Using Ohm's Law:
$$ (10\;\text{V}) - V_x = i_\text{left} \times (5\;\Omega) $$
This means (remember, we want currents for KCL):
$$ i_\text{left} = \frac{10 - V_x}{5} $$
Similarly, for the right side, we get
$$ i_\text{right} = \frac{12 - V_x}{6} $$
For the middle resistor, we have a voltage drop of \$V_x - V_\text{ground} = V_x - 0 = V_x\$, so defining \$i_\text{middle}\$ as downwards:
$$ i_\text{middle} = \frac{V_x}{10} $$
Now we have all what we need. KCL gives us
$$ i_\text{left} + i_\text{right} - i_\text{middle} = 0 $$
where you notice the negation due to my direction of the middle resistor. Plugging in the currents from above:
$$ \frac{10 - V_x}{5} + \frac{12 - V_x}{6} - \frac{V_x}{10} = 0 $$
Getting rid of fractions by multiplying with 30:
$$ 60 - 6 V_x + 60 - 5 V_x - 3V_x = 0 \\
120 - 14 V_x = 0 \\
120 = 14 V_x \\
V_x = \frac{120}{14} = 8\frac{4}{7}\approx 8.57 $$
So the voltage at the upper junction (compared to ground) is 8.57 V.


When gpg encrypt is called from the command line, how is a key chosen to do the encryption?

Question: I am using GnuPG. When gpg encrypt is called from the command line, how is a key chosen to do the encryption? It appears to me that -r, or --recipient, supplies a user id and that is the simple answer. I believe all of the examples I have looked at they show an email address for recipient, which is required input when creating your key. However, I was able to create 2 keys with the exact same user name, comment, and email address. How does gpg pick a key if there are two keys that have identical email addresses and that email address is used for the recipient? It seems to me like using key id would be the best way to do this, but I do not see that option.
Answer: Often, whenever you provide a filter to a parameter which matches multiple keys, it uses  all of them (e.g. --list-keys or --export). I was expecting it to do the same here. However, a basic check shows that it is not encrypting to all of them, but only to a single key, which is the one imported earliest to the keyring (the selection changes if imported in the other order). The command --delete-keys acts in the same way as -r, choosing just the first one present in the keyring.
You may see to which keys it was encrypted (other than by attempting a decrypt) by parsing the actual packets:
echo Hello world | gpg -e -r jdoe  | gpg --list-packets

And, as noted by CBHacking, you can use key ids everywhere. Using the textual user ids are actually simplifications for better usability.
Answer: Taking a tip from https://lists.gnupg.org/pipermail/gnupg-users/2005-June/026022.html (which I found by searching "GPG duplicate key"), you can specify keys by ID anywhere you specify them at all (such as gpg -sear 104763A0, which signs, encrypts, and base64-encodes to the recipient whose public key ID matches 104763A0). I tested this on my machine and it worked fine.
I don't know what happens if you try specifying a key that is ambiguous. Likely options are the first key in the key ring (this is what the person at the link above said was happening), the key furthest from expiration, they key you trust most, or some other sort (which might in turn influence the "first in the key ring" thing).


Wake up android device by microphone or camera

Question: I would like to install a Android tablet on a wall.
So I would wake it up by looking in to the camera(distance ~0.5 - 2 meters), by clapping my hands or something similar.
Now I'm searching for an app or a service who can handle this.
Something like ISeeYou, but working...
I will only awake my device, not unlock it.
Comment: Asking how to achieve this is on-topic, but asking for app recommendations is off-topic.
Answer: Voice control apps are plentiful, and a few will work with screen off.  Keeping the camera on all the time would chew up resources too fast so I doubt you'll find a solution there.
This kid has an app that will let Google Now listen with the screen off and then another app that will let you add additional commands.  http://rsenapps.com/


Pineapple catastrophe!

Question: I have had this pineapple plant for almost 3 years now. Just in the last 6 months have I actually been able to see noticeable improvements of growth. It's at least 4 to 5 times the size it was 6 months ago. I know it has produced pineapples already - 3 to be exact. Why hasn't it produced a flower for me yet? What am I doing wrong with it? I wish I could find out exactly how old it is . Any suggestions/advice will be greatly appreciated. I live in USDA ZONE 7B AMD 8A.
Comment: You might be summering it out but wintering in a sunny window in those zones. What is the catastrophe? Flowers come before fruit, so whatever shoot or inflorescence appears before the baby pineapples, there's your flower thing. Don't expect a showy flower.
Comment: If it is growing fast, possibly it is ready to produce pineapple. Just wait more. Maybe start looking in the center, if you start seeing the flower buds growing
Answer: Pineapples grow by producing a rosette of leaves like a Yucca, then send up a vertical spike with the fruit on top, followed by side shoots at top and bottom as vegetative reproduction outlets. Once the main crown has fruited the associated leaves and central stem die away to allow the side offshoots to take over. At this point the grower can interfere and ensure that only one strong offshoot persists to produce another fruit in its turn. If no-one takes action, multiple much smaller rosettes and fruit spikes may appear.
Since the old crown dies away what we may conclude in your case is that what you now have is a shoot that survived from the old crown. The old crown is long gone and now this one is next in line for fruiting.
As for growing area, think a location that is completely open on all sides so no shade, consistently hot and humid with lots of sunshine for long periods. Think Bahamas, Costa Rica, Florida, Hawaii, Caribbean, the tropics. The further you are from these ideal growing locations, the more often there are cold periods, particularly cold rain with poor sun exposure and you can double, quadruple, xtuple the length of time it will take to generate the internal chemistry to produce a new fruit. It may idle for long periods making no progress and then burst into life when conditions are right.
Up to you to comment whether your case mirrors this narrative.
Answer: The lifecycle of bromeliads is to flower, fruit and then slowly die while putting out offshoots or "pups".  They only set fruit once.
If your plant has already fruited then you should look for signs of growth at the base of the plant as it sends out the pups.
Comment: @MackM a pineapple only produces one fruit in a lifetime.  I don't see any pups in the picture so the information we have is inconclusive
Comment: If this plant has produced 3 pineapples in its life, does that mean at least 2 came from pups still on the mother?

Pineapple catastrophe!


Missing Applications folder inside home directory

Question: After running Disk Utility from the Snow Leopard disc, the Applications folder inside my home directory became empty or is not linked to the main /Applications folder outside my home directory. How do I restore the Applications folder inside my home?
Comment: ~/Applications is never linked to /Applications - are you sure was this the way you were set up before
Answer: The applications folder inside your home directory is not a critical folder; It's purpose is to allow non-administrator users to install applications which they may use when they don't have permissions to write to the /Applications/ folder.
If you wish to make your personal applications folder point to the global applications folder, then run ln -s /Applications ~/Applications in Terminal.
Since this is not the design, I wouldn't be surprised if Apple's repair utilities continue to remove this in the future.


How to keep items sorted based on dynamic attribute?

Question: I'm using an STL std::multiset<> as a sorted list of pointers.  The sort order is determined by a property of the items being pointed to, something along the lines of this simplified example:
struct A
{
  int x;
};

bool CompareAPointers(const A* lhs, const A* rhs)
{ return lhs->x < rhs->x; }

std::multiset sorted_set;

The complication is that the values of the property used to sort the set can change (you can change A.x in the example above), which can make the sort order incorrect:
A a1, a2;
a1.x = 1;
a2.x = 2;
sorted_set.insert(&a1);
sorted_set.insert(&a2);
a1.x = 3;

I'm able to keep the list sorted by erasing and reinserting elements when the relevant attribute changes, but the book keeping is getting to be a bit of a pain.  I feel like I'm going about this all wrong.  Can anyone suggest a better way to keep a list sorted when the sort order can dynamically change?  The changes occur in predictable ways at predictable times, but my current approach just feels wrong.
Answer: Boost Multi-Index supports sorting anything you want and supports changing the fields the list gets oderdered by, although you can't just type a1.x=1 anymore, instead, you have to use MultiIndex::replace().
I can't think of a faster/more natural way of doing this, as deleting and reinserting the element would've to be done anyway.
Comment: modify() might be a slightly better way, since elements are non-unique anyways. The main downside is that you would have to write the assignment into a functor...
Comment: MultiIndex::replace() is the suggestion that I believe best fits the situation.  It has the right balance between control, efficiency potential, and taking care of details for me.  I don't believe modify() is necessary since I'm storing pointers rather than actual objects, making element copying trivial.  Thanks for the suggestions!
Answer: I would consider using a sorted std::vector instead.  At one of those points where you predictably modify x for one of the set's members, then just re-sort the vector.  It's a little cleaner than having to remove and reinsert items.  This might be too much overhead though if you're frequently modifying a single set member's property and re-sorting.  It would be much more useful if you're likely to be changing many of these properties at once.
Comment: You could wrap the vector in another class that also keeps a boolean that is set to true whenever the vector is modified.  Then if the vector is accessed and its not sorted, sort first and return the value.
Answer: As others pointed out, using a std::set or std::multiset just does not cut it.
You probably did not notice since you use pointers, but the assumption is that objects are immutable (though in this case it means that the pointers are const, but not the pointed value).
Therefore, you cannot use (directly) a standard container which will do your book-keeping automatically.
At this point you have several solutions:

you may use a library, in this case the Boost.MultiIndex comes to mind, even though you will have to learn to use it
or you may wrap a standard container in a dedicated class (for example, your set)

I think both are equally valid. Since the operation is very simple you may not want to use the Boost library for this yet (learning curve, integration, ...).
Also, you may consider using 'invasive' containers. What I mean is that you could use the 'Observer' pattern here >> your object can notify its container each time its value change, so that the container reposition it at its 'new' correct position (using a std::multiset internally).
If efficiency is a concern, I would not consider sorting a vector. Sorting a full container each time a single object change is a waste, your erase/insert method is much more efficient.
Comment: Trust me, I noticed the immutability assumption.  It's the reason the question needed to be asked in the first place.  But I do appreciate the input.


assembly - function vs procedure

Question: In assembly language, is there a difference between a function and a procedure?
I use them interchangeably but I'm not sure this is appropriate a professional environment.
Comment: Same difference as in other languages: a function has a return value and a procedure does not.  They aren't fully interchangeable: you can call a function and ignore the return value but you can't call a procedure when you're expecting a return value.
Comment: I think they are a bit more interchangeable. Generally, you think of a function that will take and return values per the API calling convention and perform a small prologue to save the caller stack state, then perform its operation, clean up/restore any clobbered registers and exit. A procedure can be similar, here, but more of a *function-light*. you have more control of the calling convention and there generally isn't any formal requirement to save stack/base pointers before doing what needs doing, as a result of using the same call stack as the main code.
Comment: Note that opposed to most high-level languages, a "function" in assembly can return *more than one value* (i.e. all registers it changes can be considered return values if you don't consider that a procedure working on global variables)
Answer: In most (low level) assembly languages, neither the term "function" nor "procedure" exists, there are only subroutines, subroutine calls, and values returned through registers, the stack or other memory cells. In practice, it may be useful to think of these kind of subroutines in terms of functions or procedures, and talk about them using these terms, but there is probably no "standard" which defines one should only use the term "function", or "make always a clear distinction between procedures and function" in the context of assembly.
In particular assembly languages like this High Level Assembly, the abstraction of functions and procedures exist, and as you can see in the Wikipedia article, in that context both terms are used and distinguished, (at least when it is useful).
Comment: Microsoft Assembly Language (MASM) uses them both, iirc, and may be where he is getting those terms from.

assembly - function vs procedure