How does an AC circuit get anything done?

Question: if alternating current switches directions back and forth periodically it seems like to me that current would go forward a bit and then almost immediately back track the exact same distance, if this is the case then how does AC ever get to where we want it to? Could I be misconceiving AC in some way?
Comment: Possible duplicate of [Alternating current](https://physics.stackexchange.com/q/403168/)
Comment: Consider that pistons move only a small distance back and forth in an automobile engine and do so very quickly.  How can such a system move the vehicle so far?
Comment: Movement of charge is movement of charge. It usually doesn't matter in which direction
Answer: Imagine you have a crosscut saw with two handles, one on each end and a person holding each handle. The saw rests on a log to be cut. One person pulls their end of the saw and the teeth cut into the log. Then the other person pulls their end and the blade comes back, cutting further into the log.
The point is that the saw can cut the log even though it only goes back and forth, retracing its path over and over. In the same sense, AC power can perform useful work on the "pull" part of the AC cycle as well as the "push" part.
Comment: In this analogy, Direct-Current is more like a bandsaw, which is a belt with teeth that spins continuously in one direction. While AC is more like a saw with double-sided teeth, both directions apply cutting effects and an oscillating motion gets the best out of it.
Comment: This is an odd analogy, the saw does work because it consistently moves in the direction that it's cutting (generally downward) if it *only* moved back and forth, it would achieve nothing.
Comment: @DBS That's not really how saws work.  They shave off the top surface of the wood as they go across it.  One a slight amount of downward force is required.
Comment: @DBS The problem with analogies is that they can be taken too literally; read it this way - given that there exists a mechanism that makes the saw interact with the wood at the contact point (the aforementioned slight downward force, but we'll "black box" that), the back & forth periodic motion is a viable option to do useful work, with the two people being analogous to a battery. (P.S. Imagine extending the ends of the saw to form a circuit with the power source (maybe a single person or an engine) being far away.)
Comment: @DBS The saw moves downward by gravity because the wood that it cuts through is no longer there.
Comment: @JimmyJames Haha, I do understand how a saw works, the analogy just struck me as a little odd. (My point was that a saw that **only** moved back and forth would achieve nothing without another force moving the saw towards what's being cut) But I guess I'm probably just digging too far into it.
Answer: The wording of your question suggests that you might have a fundamental misconception about how electricity works (quite a common one, unfortunately, because introductory courses in electronics often get it wrong).  In an electric circuit, electric currents do not directly transfer energy.  Rather, energy is transferred through the electromagnetic fields in the space surrounding the wires.  The only purpose of the wires and other components is to guide the fields to the right places.
This is quite counterintuitive, since electromagnetic fields are invisible and we are used to thinking of electricity as something that flows inside wires.  However, the conclusion is easy to demonstrate.  The directional energy flux in an electromagnetic field (the Poynting vector) is equal to $\mathbf{S} = \mathbf{E} \times \mathbf{H}$ where E and H are the electric field and the magnetic auxiliary field (in simple cases, $\mathbf{H} = \mathbf{B}/\mu$).
In the simple circuit drawn below, the electric field points downward (since the voltage is positive in the upper wire).  Meanwhile, the magnetic field circles around the current-carrying wires; thus, it points into the screen inside the circuit.  Using the right-hand rule for cross products, we can see that the Poynting vector points to the right.  Thus, power flows from the battery to the load.  One can show that this energy flux is sufficient to explain all of the power delivered to the load.

What if we replace the battery with an AC voltage source?  Now when the voltage becomes negative, both the electric field and the current (and therefore the magnetic field) reverse their direction.  These changes cancel each other out and the Poynting vector still points to the right.  Therefore, power continues to flow from the voltage source to the load – even though every electron in the circuit stays in nearly the same place.
Comment: @Andrew the electrons move slightly counterclockwise around the circuit when the voltage is positive, and slightly clockwise when the voltage is negative.  No electrons are transferred from the source to the load – if that happened, charge would build up on the load side of the circuit, and the voltage on that side would quickly become large enough to prevent more current from flowing.
Comment: @thermomagneticcondensedboson Because there is virtually no electric field inside the wires, since they are made of a conductive material.
Comment: @thermomagneticcondensedboson In Ohm's law $J = \sigma E$, $\sigma$ is the conductivity, which is very high (for simple problems like this one, effectively infinite) in a metal wire.  Therefore, to allow a finite current density, the electric field must vanish.
Comment: The full Poynting vector also includes a term for mechanical transfer of energy, i.e. electron KE in this case. For electron flow this is negligable compared to the regular Poynting vector but it still does exist. See  https://physics.stackexchange.com/questions/17085/is-there-something-like-the-poynting-vector-for-hydraulic-circuits
Comment: Err... What about electrons, though? Isn't that a transfer of energy?
Comment: But there is an electromagnetic field inside the wires... why don't you say anything about that energy?
Comment: This is wrong Thorondor. J =sigma E. The electric field is directly proportional to the current density inside the wire. Saying that it almost vanishes is definitely wrong.
Comment: You're right, good point. To improve your answer, it would be nice if you could compare the E field inside a good conductor (say copper) and outside it (say with a few V applied). This would make a very good answer. I mean, plug in numbers to see the difference.
Answer:
and then almost immediately back track the exact same distance

Current travels, very approximately, one foot per nanosecond. Mains 50Hz cycles have a period of 20,000,000 nanoseconds. It's very far from "almost immediately".
Comment: This doesn't really address the fundamental misunderstanding that is confusing the asker. The distance traveled by the current each half period is not really material to the way the work is performed, and it does indeed travel the same distance in the opposite direction during the second half of each period, regardless of the distance traveled.
Comment: The asker thinks that 1/60th of a second is "almost immediate", but for an electric field moving at (nearly) the speed of light, that's enough time to travel across a continent, or zoom through the circuits in your device many thousands of times.
The confusion is (in part) due to not understanding the vast difference between the speed of humans vs the speed of electricity.
Answer:
If alternating current switches directions back and forth periodically it seems like to me that current would go forward a bit and then almost immediately back track the exact same distance, if this is the case then how does AC ever get to where we want it to?

See this microscopic view of current, and understand that the electrons do not travel fast within the conductor, but have a drift velocity. This drift velocity , according to the classical electrodynamics equations, is what generates the current measured in the lab. In a DC circuits the electrons move slowly towards the potential , in an AC current they move back and forth, but the macroscopically generated  current has a direction from high potential to low potential.
The reason that AC has prevailed in the transmission of electric power is practical considerations. When DC is transmitted one has to generate AC at home to get motors running, for example.
Comment: The Drude's model is known not to be an accurate description of reality. The speed of the electrons that conduct is about the order of the Fermi speed, i.e. about 1% of light speed in metals.
Comment: @thermomagneticcondensedboson Of course a model that does not include quantum mechanics cannot be the "real" one, as main stream physics is based on quantum mechanics being the underlying frame of classical. But it is useful, as the planetary model of the atom was useful (and still is) when physicists first found out that it described the data  in the correct direction.
Answer: Alternating current transmits powered by varying electric fields which makes the electron oscillate this oscillating energy transmitted through the wire in the form of electric fields and the energy is transmitted where it needs to be transmitted.
For example in a electric heater the alternating current oscillates electron in the filament which produces heat.
But in dc heater there is a continuous flow of electron which generates heat due to resistance.
Comment: But DC current can cause heating, transfer power, etc. too. This answer isn't helpful, as it basically just says AC works because it works.
Comment: The edit didn't really help alleviate @AaronStevens concerns, since it's the resistance that results in heat in an AC heater also. If anything all you've done is made it less clear.


Intermittent KVM performance issues causing performance glitches

Question: We are currently hosted on a hosting provider that allows us to set up multiple virtual machines using KVM, where each virtual machine runs on it's own physical box (ie: one hypervisor, one VM with all the memory and CPU allocated to it). Recently we ran into some nasty problems we needed to diagnose (turned out to be stack overflows - lol). In the process we set up DataDog to monitor all our servers and it helped us narrow down the cause and eventually fix it. But we found it super useful we left it all enabled. In the process of learning the tools we keep seeing slow response times during the day for our web sites. Enabling APM tracing we have been able to narrow it down to poor response time from our MySQL cluster. Sometimes we will see MySQL connections take 900ms or longer to get created, and other times dead simple queries like setting the connection collation or the timezone take 600ms or more. Queries that normally run in in less than 800 microseconds.
To diagnose the problem we set up pings to multiple endpoints in our cluster, and have two pings that regularly run slow (4-5s at times!) that simply do noting but return a string (PHP/apache version) or return some client IP information (.net and IIS version). We set those up to see if we would see issues on Linux or IIS without anything else involved, and we do. Oddly during the times we get these outages the CPU on the machines is very low, same on the MySQL cluster. When the queries are running slow, CPU is super low as those boxes generally sit around 5-6% CPU most of the time.
To try to work out if this was a networking issue, we set up captures using Wireshark on windows and dumped the packets while we had some decoration in the queries so we could find them in the packet dumps easily (basically set a MySQL variable in the query that is an encoded version of the current UTC timestamp in microeconds). Using that we were able to correctly match up long MySQL spans in DataDog APM with the packets in the TCP dumps. Looking at the Windows/IIS side, we could see that all the time was spent waiting for the result to come back over the wire from the MySQL server. So the time reported in DataDog for the MySQL query exactly matched up with the time in the data dumps.

So as you can see from the two screen shots, they match up exactly. To determine if the networking issue happened on the MySQL side, we then did the same capture dump again on the Linux machine and saw the exact same thing. MySQL got the request, and a huge number of milliseconds later it sent the reply. So the issue is clearly not networking, but something causing MySQL itself to slow down.
Now what is really odd is that it's not MySQL itself getting blocked up, because the particular box I ran those queries against was only running read queries from one of our windows virtual machines, as a read slave. So it did not have much load on it, and during the time of the queries the CPU load was probably 3% (it has 16 CPU physical cores with dual 8C Xeon CPU's, and 32 vCores allocated to the VM). So clearly not a load issue on the MySQL server, and more importantly from the TCP dumps it's clear that while the query we were interested in was taking a long time to execute, plenty of other queries from other connections came along and got processed with no delay.
Now to top it all off, we have also found in our logging that the MySQL slave will routinely get way behind, 30-40 seconds behind the master. We have seen cases where it got up to 110 seconds behind the mater, which makes zero sense as the machine has low load on it, and it's all on the same local private network that the master database (and web servers) is on. Sometimes those delays in the slave occur around the same time the slow downs happen, and some times they do not.
So now that we have conclusively determined that we do not think this is a networking issues, we are starting to think this is some kind of thread deadlocking issue in KVM itself? Especially because we see super odd slow downs in all our virtual machines, some of which have nothing to do with MySQL (such as the static PHP hello file). Since we don't have any control over the KVM layer so we do not know what version it is running on now how it is configured. But the more we look into this perplexing problems, the more the finger is pointing at KVM as the root cause of this, but we have no idea how to resolve it.
To illustrate the problem, here is a ping of a PHP page that just echo's 'hello' and does nothing else, and the ping times from three AWS servers. Clearly you can see big spikes in there at times.

Now you might simply argue, but that is networking! Of course you might have glitches from AWS talking to that server during the day. True enough, but here is a ping during the EXACT same time period from the EXACT same AWS servers to a static page in Apache measured in milliseconds this time (less to do than PHP having to server up even a simple page):

So as you can see it is not external networking either, because the static file ping was never slow. No issues at all. We actually set up that static file ping to run against a second instance of Apache on that box to ensure it has zero load on it to get a baseline. At the end of the ping you can see stuff started going a bit nuts and the ping times are all over the place. That's because we just enabled PHP in that instance and served up the same hello.php file from that second apache instance to see what different it would make. Primarily because the first instance is also serving real live traffic to our wordpress blogs and ad servers (low volume traffic, but its not zero). So clearly once we add something to the mix that uses a lot more CPU, things start to go wonky.
So my question is, has anyone else ever experienced this kind of problem before with KVM, and if so, how do you resolve it? We are on the verge of ditching this KVM solution and migrating either back to dedicated machines again (which we ditched a decade ago), moving to a private VMware cloud or considering moving to Google or Azure (both of which will cost us a lot more money). But I fail to see the point in moving to another cloud architecture like Google or Azure or a private VMware cloud, if they might have similar issues?
Any suggestions?
Comment: Additional information request from slow BIKE
Any SSD or NVME devices on MySQL Host server?
Post on pastebin.com and share the links.
From your SSH login root, Text results of:
B) SHOW GLOBAL STATUS;    after minimum 24 hours UPTIME
C) SHOW GLOBAL VARIABLES;
D) SHOW FULL PROCESSLIST;
E) complete MySQLTuner report
AND Optional very helpful information, if available includes -
htop OR top  for most active apps,
ulimit -a       for a Linux/Unix list of limits,
iostat -xm 5 3 for IOPS by device and core/cpu count,
for server workload tuning analysis to provide suggestions.
Comment: Is it DansComp.com with the delayed response?
Comment: If you are changing Thread_handling from pool-of-threads to one-thread-per-connection, consider threadpool_threads=0  and thread_cache_size of 100 to minimize threads_created.
Answer: Rate Per Second = RPS
Suggestions to consider for your my.cnf [mysqld]
<code>read_rnd_buffer_size=128K  # from 256K to reduce handler_read_rnd_next RPS of 262756
innodb_lru_scan_depth=100  # from 1024 to conserve 90% of CPU cycles used for function
innodb_flush_neighbors=2  # from 0 to speed reduction of innodb_buffer_pool_pages_dirty of 148,465
sort_buffer_size=512K  # from 256K to reduce sort_merge_passes RPhr of 1370
innodb_io_capacity=1900  # from 200 to use more of available SSD IOPS capacity
</code>
This is only first five performance improving suggestions.  There are many more to consider.
Please view profile, Network profile for contact info and free downloadable Utility Scripts to assist with performance tuning.


Harry Potter grammar question

Question: In the book Harry Potter and The Chamber of Secrets, Chapter 2, page 14, last paragrapgh appears 2 sentences like this, "They lets Dobby get on with it" and "Sometimes they reminds me to do extra punishments...". My questions is Why is the third-person rules used with REMIND and LET? thnx
Comment: It's just a part of his characterisation. Just like when you characterise non-native English speakers as speaking/writing like this.
Comment: It's just nonsense (bit like Harry Potter really!)
Comment: @EdwinAshworth I disagree entirely. It's a well-known cockney idiom. We often discuss regional expressions on the site.
Comment: @EdwinAshworth Let's see if Colin responds (he's more a Londoner than you or I). He describes it as "rustic" - I tend to think of it as cockney. (That's interesting in itself since he's a metropolitan, and I'm a yokel -in origin). But I'm sure I've heard Cockneys use that conjugation - whether for emphasis, or simply out of ignorance - "I hates it when that b*****  Chelsea mob turn up here" is what I suggest you might hear at a home match at West Ham.
Comment: @Colin Fine Can you settle this argument? You have described it as "rustic", I think it's "cockney", and Edwin, a Lancastrian, doesn't recognise it as regional at all.
Comment: I'm voting to close this question as off-topic because it is not about standard English usage. Interpreting / explaining literature etc is often a matter of accepting that authors don't stick to rules.
Comment: @WS2 'They lets Arthur/Joan ... get on with it'? You're claiming that this is utilising a well-known cockney idiom?
Answer: Because that's how Dobby speaks! It's meant to be non-standard English, like his referring to himself in the third person. It's how house elves in general speak in the Potter universe, I believe. Kreacher also referred to himself in the third person, though, off the top of my head, I don't remember what he did with third-person plural verbs.
You'll find the same kind of thing in Tolkien's books with the character Gollum, who also refers to himself in the third person (indeed, for some reason, lack of a grasp of pronouns is common across literature and the media for creatures of limited intelligence or limited grasp of the language, or for robots) and also refers to hobbits as "hobbitses". Wikipedia covers Gollum's speech.
Comment: Good answer. I would add that these particular forms of speech are associated with marginal and despised parts of the English-speaking world (for example, rustics). Contrast the non-standard grammar of Yoda (in Star Wars): his speech patterns are not familiar from any existing English variety, and so do not carry those social connotations.

Harry Potter grammar question


How did the spices help?

Question: Rashi (Bereishis 37:25) quotes the Midrash explaining Arab caravans ordinarily carried foul smelling cargo like tar and petroleum, yet Hashem ensured the caravan Yosef was sold to would carry pleasant spices instead. That being the case, how could the nice aroma really help Yosef get through the frightening journey and excruciating betrayal of his brothers?
Comment: My Rebbeim taught me that Hashem is exact in His decrees. The lesson here is that a bad smell was not part of the decree, so Hashem arranged for an unusual event so as not to add anything worse than the gezeirah itself.
Comment: I heard a "d'var Torah" in which this question was asked, and the answer was something like "Hashem was letting Yosef know he was there" (no source).
Answer: Rashi doesn't say anything about the spices being helpful for getting over emotional trauma.

וגמליהם נושאים וגו' - למה פרסם הכתוב את משאם להודיע מתן שכרן של צדיקים שאין דרכן של ערביים לשאת אלא נפט ועטרן שריחן רע ולזה נזדמנו בשמים שלא יוזק מריח רע

He explains that they brought spices so that bad smell of their usual wares wouldn't bother him.
Comment: שלא יוזק (lit. _so he wouldn't be harmed_) sounds perhaps even more serious than just _wouldn't bother him_ -- i.e. an actual health hazard.
Comment: Great point Zev! I'm still looking for an answer because of the implication of Rashi of 'damage'
Answer: A good answer is provided by Rav Chaim Shmulevitz zt"l in his Sichos Mussar, Maamar 16. He describes how Yosef had experienced a great deal of trauma - he was the 'ben zekunim' (the son of old age) of his father, who was now being sold into slavery, heading to Egypt which was entrenched in tumah (impurity). It was pretty much impossible to escape from a place like Egypt, and it all happened so suddenly. As such, Yosef was in a state of mind where he could well have completely given up all hope.
However, by having the sweet smelling spices it was sign from Hashem that Yosef had not been forgotten. Hashem was still very much there 'holding his hand'. Rav Shmulevitz writes:

בשעה קשה זו נרמז לו מן השמים שאין הדבר כן, ד' עמו ועדיין תחת השגחתו יתברך, ואין לו לאבד את בטחונו בהשי"ת. הקב"ה מזמין לו ריח טוב שלא כדרך הטבע , להורות לו שאין "אבוד" ו"נשכח", אלא אדרבה הקב"ה מוליכו יד ביד והוא וירד עמו מצרימה, כדרך שאמר הקב"ה ליעקב: "אנכי ארד עמך מצרימה ואנכי אעלך גם עלה" (בראשית מו:ד) ריח בשמים זה הרי אוה קרן אורה בחשך שבו הוא נתון, ועל ידו נפתח ליוסף פתח תקוה לחזור ולהתרומם משפל מצבו, כענין שאמר יונה הנביא (יונה ב:ה): "ואני אמרתי נגרשתי מנגד עיניך [העלמת עין ממני] אך אוסיף להביט אל היכל קדשך". ופרש"י "כשראיתי שקיימתני כל הימים, ידעתי כי אוסיף להביט אל היכל קדשך"
At this hard time it was hinted to him from Heaven that the matter was not so (i.e. so difficult and terrible), Hashem was with him and he was still under His blessed Providence, and he mustn't lose faith in Hashem. G-d prepared for a him a nice smell that was not the natural way to teach him that he was not "lost" and "forgotten", and rather quite the opposite, Hashem was leading him hand in hand, and descending with him to Egypt, just like what Hashem told Yaakov -"I will go down with you to Egypt, and I will also bring you back up" (Bereishis 46:4). The smell of spices, was a sign. It was a ray light in the darkness in which it was placed. And through this, it opened to Yosef a sense of hope that he would rise again from the depths of his situation. Like it says by Yonah HaNavi (Yonah 2:5) "I thought I was driven away Out of Your sight (i.e. You turned a blind eye to me), Would I ever gaze again Upon Your holy Temple?" - And Rashi explains, "I saw that You have kept me alive all these days. I know that I will continue to gaze upon Your Holy Temple."
(My translation and emphasis)

Thus, according to Rav Shmulevitz, the sweet smelling spices served to show Yosef that Hashem was with him, and that all the suffering he was to endure still came from a place of love.
Answer: In Rabbi Jachter's Depths of Yonah, he writes:

"The Torah records that the caravan that transported Yosef to slavery in Egypt was carrying fragrant spices such as balsam and lotus. Chazal and Rashi wonder why the Torah records this seemingly-trivial detail, which appears entirely irrelevant to the story. Why does Hashem feel it is important for us to know the cargo contents of the caravan?
Rashi (to Bereishit 37:25), following Chazal (citing Bereishit Rabbah 84:17), explains that normally Arab caravans carried foul-smelling items such as resin and tar. Hashem arranged that the caravan transporting Yosef would feature fragrant spices so that Yosef need not suffer from the malodorous wares.
This teaching is quite puzzling. Yosef is being transported to Egypt to live a miserable existence as a slave. Yosef's privileged life as Jacob's favorite son was transformed instantly to a wretched reality. How would Hashem's arranging for the caravan to carry sweet smells help Yosef in any significant manner? Odoriferous cargo would have appeared to constitute the least of Yosef's newly-encountered problems. The situation would seem analogous to someone who, God forbid, was kidnapped by ISIS and Hashem arranged for the vehicle transporting the victim to be pleasant-smelling. What benefit does the victim in such horrific circumstances have from the pleasant smell?
One answer is that Yosef was a highly intelligent person, as Onkelos and Rashi (to Bereishit 37:3) point out. He therefore realized that it was unusual for an Ishmaelite caravan to be carrying sweet-smelling spices. Add in the fact that caravans tend to be terribly malodorous because they are filled with sweaty men and animals traveling through a scorching desert, and having a good smell in such circumstances becomes not just rare but almost unheard of.
Yosef realized that this rare occurrence must have been a subtle message from Hashem that He is with him and that He orchestrated his sale to Egypt for a purpose. This message Yosef eventually articulated confidently to his brothers. Yosef did not need a divine revelation to ascertain this information; he needed only a sense of logic and sensitivity to his surroundings to become conscious of Hashem's involvement. The ongoing and eventually dramatic turn of events during Yosef's time in Mitzrayim (Egypt) encouraged the same train of thought and led Yosef to detect and identify Hashem's continued support and intervention."

I infer from his chiddush that had Yosef gone on a regular caravan, with the foul-smelling "works", he would have felt total despair. This uncharacteristically sweet-smelling caravan was a sign of continued hashgachah from Hashem.
Answer: I understand the question as follows:
Why would Yosef honestly care what the camels were carrying? Let us say you are being kidnapped and the kidnapper is wearing some nice aftershave, would that really cheer you up?
The answer would appear to be that this was a sign to Yosef that God was with him in his travails.
Answer: There is, perhaps, a theme in the thought of Chazal that even though a righteous person must undergo a specific hardship or trial, it can be made as pleasant as possible under the circumstances. Thus, Sotah 12a reports about the pitch made outside of Moshe's ark (compared with Noach's ark):

ותחמרה בחמר ובזפת תנא חמר מבפנים וזפת מבחוץ כדי שלא יריח אותו צדיק ריח רע

The verse continues: "And daubed it with bitumen and with pitch" (Exodus 2:3). A Sage teaches: She daubed bitumen on the interior and pitch on the exterior, so that righteous person, i.e., Moses, would not smell a foul odor, such as that of pitch.

So too here for Yosef's conveyance to Egypt, in Bereishit Rabba 84:17, which is Rashi's source:

אָמַר רַבִּי אַבָּא בַּר כַּהֲנָא וַהֲלֹא אֵין דַּרְכָּן שֶׁל יִשְׁמְעֵאלִים לִהְיוֹת טְעוּנִים אֶלָּא עוֹרוֹת וְעִטְּרָן, אֶלָּא רְאֵה מַה זִּמֵּן הַקָּדוֹשׁ בָּרוּךְ הוּא לְאוֹתוֹ צַדִּיק בְּאוֹתָהּ שָׁעָה, שַׂקִּים מְלֵאִים בְּשָׂמִים כְּדֵי שֶׁתְּהֵא הָרוּחַ מְנַשֶּׁבֶת בָּהֶם מִפְּנֵי רֵיחָן שֶׁל עַרְבִיִּים.

that besides the typical smell that he would otherwise suffer (which is tar, same as what Moshe avoided), there was also the typical odor of these merchants, perhaps because of their dealing in such odiferous substances. The wind blowing on these sweet spices helped mitigate this.
The midrash doesn't use the word נזק, but that is Rashi's expansion of the idea, where Rashi saw the original source, and so I would not read to much into this word choice. In context, the point is avoidance of additional negative smells, and the "harm" avoided is the unpleasant odor, rather than any physical bodily long-lasting injury. Hezek re'iyah is harm, but not physical bodily long-lasting injury.

How did the spices help?


Forwarding ICMP over a server without redirects

Question: I need to test network characteristics like RTT in a network for example by using ICMP pings.
This question is special since I want to force every packet over a server who needs to work like a router but is not allowed to propose redirects. But exactly this is not possible, instead, I always lose the connections between hosts.
The network was set up (in "ip route" / routing tables) to first pass all packets to a server (IP: 10.0.0.4) who then sends it back to the gateway (IP: 10.0.0.1). From the gateway, it is routed to the correct host (IP: 10.0.0.5 - 10.0.0.255).
In the future, this scenario will enable a server to alter all packets in the network.
To simplify the scenario, only two hosts are set up (10.0.0.5 and .6). The hosts are then configured with the following routing table (showed for 10.0.0.5):
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.0.1        0.0.0.0         UG    0      0        0 ens3
10.0.0.0        *               255.255.255.0   U     0      0        0 ens3
host-10-0-0-6.o host-10-0-0-4.o 255.255.255.255 UGH   0      0        0 ens3

For the server 10.0.0.4 the routing table is as follows:
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.0.1        0.0.0.0         UG    0      0        0 ens3
10.0.0.0        *               255.255.255.0   U     0      0        0 ens3

The iptables are completely empty at this point for all devices. Further, to allow IP-forwarding the server was configured with /proc/sys/net/ipv4/ip_forward=1
With this setting I can easily ping between the two hosts, the output is as follows (for host 10.0.0.6):
# ping 10.0.0.5
PING 10.0.0.5 (10.0.0.5) 56(84) bytes of data.
From 10.0.0.4: icmp_seq=1 Redirect Host(New nexthop: 10.0.0.5)
64 bytes from 10.0.0.5: icmp_seq=2 ttl=64 time=0.441 ms
64 bytes from 10.0.0.5: icmp_seq=3 ttl=64 time=0.405 ms

The problem is the ICMP-redirect that the servers immediately sends. With this, all ping-packets do not pass the server anymore.
I have tried many things, including altering the iptable to drop redirects and changing the sysctl.conf file with net.ipv4.conf.all.accept_redirects = 0 and net.ipv4.conf.all.send_redirects = 0 (respectively for the interface ...conf.ens3....)
The problem is, every time I disable redirects, the ping is no longer possible at all (100% packet loss).
How can I make this (supposed to be) simple scenario work, meaning: How can I route all packets every time over a server and back?
Answer: You need to prevent BOTH the server and the router from SENDING icmp redirects to the source host.
If it is a cisco router, "no ip redirects" will do that.
On the server, depends on your linux flavor, this link has info for all the flavors and various ways to Disable ICMP Redirects in Linux
http://www.itsyourip.com/Security/how-to-disable-icmp-redirects-in-linux-for-security-redhatdebianubuntususe-tested/comment-page-1/


Gravity on a Cube World

Question: Say that you have a planet that, instead of being spheroid, is cuboid. How would such a planet form? Wouldn't the gravity pull the matter toward the corners toward the center, causing the planet to revert to a sphere? (Hoping for an answer rooted more in hard science and less in reversing the polarity.)
Comment: @RadovanGarabík That's the second half of the question, how gravity would pull on people. But the first question still remains - how would such a planet form?
Answer: It would not form on its own

Wouldn't the gravity pull the matter toward the corners toward the center, causing the planet to revert to a sphere?

That is part of the very definition of a planet; that the planet has achieved so called hydrostatic equilibrium.
So if you find a cubic shape in space, it would by definition not be a planet. It would also be very small, not more than the size of large asteroid / dwarf planet. And it would in all likelihood be artificially made, because the only natural formations that turn out cubic are crystals, and those are way too dense to be able to maintain their cubic shape when reaching planet size.
Comment: @DonielF The distinction is not arbitrary. Above a certain mass limit, the body will deform into a sphere. See [this](http://physics.stackexchange.com/q/130789/56299), [this](http://physics.stackexchange.com/q/29427/56299), [this](http://physics.stackexchange.com/q/139710/56299), [this](http://worldbuilding.stackexchange.com/q/8772/627), [this](http://astronomy.stackexchange.com/q/5918/2153), and links therein.
Comment: @DonielF For as long as it takes the magic that formed it to go away. No, really, that is the only answer you can ever get because such a planet can **only** form by magic, i.e. some kind of force far outside our present knowledge of physics. And when that magic goes away, your planet will collapse into a sphere. How it will happen, during how long time and so forth, is anyone's guess. You, as the author, can make up whatever you wish here since you are firmly outside the realm of science anyway.
Comment: @HDE226868 beat me to the punch as I was writing the answer. +1 on what they said: it is not an arbitrary limit... it is a physical certainty that it will happen. If you want a cube-shaped body in space it need to be fairly small, or fairly low density (way lower than rock). And it cannot form naturally, someone must have *built* it. The only natural formations that turn out cubic are crystals, and those are way too dense to be able to maintain their cubic shape when reaching planet size.
Comment: Okay, fine, so it's arbitrarily not a planet because a group of scientists said so. Now what? It's a large mass of rock in the shape of a cube. Is it possible for it to retain that shape, or will it deform into a sphere?
Comment: @MichaelKarnerfors Why don't you integrate your last comment directly into an answer?
Comment: @Mołot Done now, thank you for the tip.
Comment: So basically if by some extremely low chance this thing does form naturally, how long roughly would it take for it to fall into a sphere without outside intervention?
Comment: @Michael Alright, thanks. Wasn't sure if it would just collapse, or if it would take some time for it to do so.
Answer: Leaving aside the issue of how could a cubic planet be formed, or how could it keep its cubic shape, let's understand how it feels on the ground. If physic laws as we know them apply to it, those living upon it - or merely visiting - won't feel it like a cube. They will feel it like a planet with eight monstruous mountains. Yes, you guessed right, those monstruous mountains are the vertexes of the cube. Everything will roll down those mountains to the plains in the centre of each face of the cube. This includes water and atmosphere: the oceans, if there are any, will be at the centre of each face, and their surface will not run parallel to the solid surface of the planet; it is going to be curved, and its curvature will be that of a spherical cap. The same goes for atmosphere; the atmospheric pressure in the centre of each face is going to be much higher than in the vertexes. You know that Earth's atmosphere is already irrespirable at the top of the Everest. Consider that the Everest, tall as it is, hardly makes the Earth look polygonal; what happens in a cubic planet is that either the atmosphere is inexistent at each vertex - and in a huge area around each vertex - or irrespirably dense at the centre of each face.
How tall would those monstruous mountains be? Suppose the distance from the centre of each face of the cube to its baricentre is 12,000 kilometers - so that gravity there would feel like gravity on the surface of the Earth. Now, your planet would be like a cube circunscribed to a sphere the same size of Earth. The vertexes would then be at 16/pi^2 multiplied by 12,000 kilometers from the centre. This is a little more than 1.6 times 12,000 km - or some 19,400 km. Which means, those would be mountains 19,400km - 12,000km, or 7,400km tall. Mountains about 900 times taller than the Everest.
Such things would crumble down catastrophically if your planet is governed by ordinary laws of physic. So, if you really wish a cubic planet, the region of space in which it is placed must have different laws of physics. Those will be complicated, and will need to be taylored to the specific effect you wish (if you want for each face of the cube to feel like a plane landscape, it needs given physic laws; if you want them to feel like described above, but even then to the planet somehow keep its shape, then you need a different set of physic laws).
I have no idea of what such physic laws should be, but this gives you the question that you need so that you can get the answers from the physic-enabled minds here; you need to ask what should the laws of physic be so that a cubic planet could be possible.
Comment: Different laws of physics are not necessarily needed. The "planet" could always be made of ultradextraterpomadeltrium, a newly-discovered compound that has remarkable properties that, among other things, allow it to retain a cubic shape at sizes previously thought impossible.
Comment: I fear that *ultradextraterpomadeltrium* would have to be composed of extraordinary electrons and protons to have those remarkable properties, and that those extraordinary particles would require different laws of physics. By the way, would a cubic planet orbit around a cubic star? Along a square orbit? Would its atoms be cubic?
Comment: @Devsman that would also imply an artificial object, not a naturally ocurring planet, since ultradextraterpomadeltrium doesn't aggregate in cubic shapes from planet-forming dust by itself. In essence, that wouldn't be a question about planets but rather about very, very large space stations.
Answer: Well gravity works as mass attracting mass, so even if the mass of the cube was cubical, the cube would still work as if there was a sphere underneath. So standing on the center of one side, you would stand vertically, while if you were on the edges, you would be pointing towards the exact center. (so at an angle to the horizon).
However, as you would be further from the center you would be pushed towards it, yes.
Somewhat similar to how you are "pushed" downhill on our planet.
Unfortunately, this also means that any large shape floating in the universe would eventually become a sphere, as it is attracted to the center of itself.

Gravity on a Cube World


Hierocles and Pythagorean Library

Question: In Pythagorean Library, a complete collection of the surviving fragments from the Pythagoreans, the initials fragments are those that belong to Hierocles, and in several of them, between parentheses — likely as an explanation/English-analogue to those Greek "proverbs" —, it is mentioned "God" (in capital G and singular, instead of "gods"). To my knowledge, polytheism was very much alive at that time and Hierocles was not known for being a Christian. So, are the mention of "God" there in the books an adulteration or what?
Comment: Hierocles is thought to be from around 450 AD, plenty of non-Christian philosophers in the hellenistic world had proposed versions of God by then, like Aristotle's First Mover or the notion of The One which showed up in Plato's [Parmenides](https://en.wikipedia.org/wiki/Parmenides_(dialogue)#Discussion_with_Aristoteles) and was elaborated on in the "neoplatonist" tradition started by [Plotinus](https://en.wikipedia.org/wiki/Plotinus#One). I don't know specifically if Hierocles was inspired by any of these but it wouldn't be surprising.
Comment: Hierocles was a neo-Platonist, and they had their "God" (the One). That aside, that those are "surviving fragments" is very doubtful. There is a distance of a millenium between Hierocles and Pythagoreans, and there is no clear transmission from them to neo-Pythagoreans from whom these fragments are derived. The Golden Verses, that neo-Platonists were fond of and used in instruction, are known to be a late fabrication, for example.
Answer: The source in question contains a grave mistake. The Pythagorean precepts (σύμβολα) pose a complicated challenge to the history of philosophy. They are traced back to Alexander Polyhistor, who notes that he himself is a transmitter of them. One may refer to (1) for a collection of them in the original and translated languages. Lest we delve into the labyrinths of doxography, I shall be content with stating just that they are consonant with the polytheism of Antiquity and are not handed down from Hierocles of Alexandria.
At present, we are aware of two works of Hierocles, and no other. One of them is his commentary on the Pythagorean Golden Verses (Χρυσά Έπη, a.k.a. Carmen aureum by their Latin title) which we have in full; the original text is given in (2). The other one is On Providence (Περί Πρόνοιας) extant in fragments and summary in Photius' Bibliotheca (Βιβλιοθήκη).
Though Hierocles is not a Neoplatonic philosopher per excellentiam, he adheres to the core Neoplatonism. Seemingly, the characteristic henology is replaced by a demiurge.
Generally speaking, it ought to be kept in mind that the One of Neoplatonism must not be conceived in a simple numerical sense and conflated with the God of the Abrahamic religions (some translators have distorted the distinction, to be sure). As for Hierocles, the following from Hermann Schibli's eloquent entry "Hierocles of Alexandria" illuminates the point:

That Hierocles forgoes a Plotinian union of the soul with the One can
thus be explained from his strict notion of the cosmic order and not
because his ontological hierarchy is lacking the Neoplatonic One from
which all things emanate. It is true that in his extant writings
Hierocles does not explicitly mention the One. This omission has led
some scholars to suppose that Hierocles represented an "Alexandrian,"
pre-Plotinian brand of Neoplatonism, in which the demiurge is the
absolutely highest principle and which thereby approximates Christian
monotheism. The major obstacle to this theory, however, is that
Hierocles (Comm. 20.12–19) unambiguously identifies the demiurge with
the Pythagorean symbol of the number 4, called the tetractys or tetrad
(the paradigmatic model of the physical world), which is itself a
derived principle (from the monad, the principle of number). The
demiurge/tetractys therefore represents a subordinate hypostasis and
the One may be assumed to stand in the background of Hierocles's
metaphysics as the very first transcendent principle, in harmony with
the philosophy of Ammonius and Hierocles's own teacher, Plutarch of
Athens. It is understandable that Hierocles did not introduce the One
in his Commentary, since that work is chiefly an ethical treatise that
was not required "to extend to the whole of philosophy" (Comm. 27.10).
As for the On Providence, of which we have only meagre remnants
anyhow, the subject matter would not necessarily entail a discussion
of the One (just as Plotinus's Enneads 3.2–3, "On Providence," do not
include the One).

For an in-depth study of Hierocles' Commentary, I would recommend Schibli's (3).

(1) The life of Pythagoras, with his Symbols and Golden verses. Together with the life of Hierocles, and his commentaries upon the verses. Collected out of the choicest manuscripts, and tr. into French, with annotations. André Dacier, translated by Nicholas Rowe. London, printed for J. Tonson, 1707. Freely available at https://archive.org/.
(2) Hierocles in aureum pythagoreorum carmen commentarius. Edited by Friedrich W. Köhler. Stuttgart: Teubner, 1974. Freely available at https://archive.org/.
(3) Hierocles of Alexandria. Hermann S. Schibli. New York: Oxford University Press, 2002.

Hierocles and Pythagorean Library


Does deleting an account delete the associated posts and comments?

Question: Suppose user X wants her account deleted. She has answered a bunch of questions and participated in several comment threads. Suppose the account is deleted; will the associated answers and comment threads disappear too?
Comment: Related: [What is the difference between a deleted user and a "destroyed" user?](https://meta.stackexchange.com/q/88994)
Answer: There are two ways moderators can delete an account.
The first way leaves questions and answers having 0 or positive score intact, while automatically deleting negatively scored posts. The user's handle still appears in his posts, with a "ghost figure" replacing his Gravatar.
The second way deletes all posts and comments associated with the account.  We use this option for users who are just here to spam the website with their latest product.  Call it the "nuclear option."
Comment: Note that regular delete removes anything that is negatively voted.


How can I teleport a player from a specific place to another in Minecraft Bedrock Edition using command blocks?

Question: I'm making a multiplayer map, and I need to teleport a player from one place to another. However, I have all the command blocks set up at a separate area, so I cant just say /to @p [x y z]. Is there any way to teleport a player from one particular spot to another?
Answer: You can use this @a[x=~,y=~1,z=~,dx=0,dy=0,dz=0] to target any player who is on top of the command block that is executing the command.
This command will teleport any player at the coordinates 100 50 100 to 150 60 150:
/tp @a[x=100,y=50,z=100,dx=0,dy=0,dz=0] 150 60 150

Comment: I haven´t tested that command in the java edition, but it should work there, too
Answer: If you wanna check for a specific block. Use this one:
execute @a ~ ~ ~ /testforblock ~ ~-1 ~ <name of block>

Then use a redstone comparator to activate the second command block which is using to teleport player around.


Visual Studio natvis displaying pointer-to-interface

Question: I'm trying to create debug visualizers for our company custom smart pointers. I would like to use ExpandItem to get the contents just one level down, which works for concrete types like ref_ptr<Vector2d>, but not for virtual types like ref_ptr<IStreamManager>. When using the virtual types, I get two entries, one for the underlying type, which I can then expand, and one for the __vfptr.
What I'm getting:
v streamManagerPtr         shared_ptr { count=35, ptr=... }
    [Reference Count]      2
  v [StreamMgr]            {...}
      m_resourceMgr        shared_ptr { count=35, ptr=... }
      m_fileMgr            shared_ptr { count=23, ptr=... }
      ...
  > __vfptr                0xdeadbeef
  > [Raw View]             {...}

What I want:
v streamManagerPtr         shared_ptr { count=35, ptr=... }
    [Reference Count]      2
    m_resourceMgr          shared_ptr { count=35, ptr=... }
    m_fileMgr              shared_ptr { count=23, ptr=... }
    ...
  > [Raw View]             {...}

Is there any way to bring the contents of the underlying dynamic type up one more level so I don't have to deal with this useless level of nesting?
Answer: I believe you can use something like this:
<Type Name="shared_ptr<*>">
  <Expand>
    <ExpandedItem Condition="ptr != 0">*ptr</ExpandedItem>
  </Expand>
</Type>

The ExpandedItem tag basically removes a level of nesting, displaying the contents of the item in the tag as though they were regular items at the same nesting level as the rest of the Items in the Expand tag.
Comment: `ref_ptr` is not `std::shared_ptr`, so this will have no effect.
Answer: I am not using ref_ptr, so I tested with my own template class. So please be mercy if the following code might not immediately work with ref_ptr.
<Type Name="ref_ptr<*>" Priority="MediumLow">
  <Expand>
    <ExpandedItem Condition="_ptr->__vfptr">*_ptr</ExpandedItem>
  </Expand>
</Type>
<Type Name="ref_ptr<*>">
  <Expand>
    <ExpandedItem>_ptr</ExpandedItem>
  </Expand>
</Type>

The trick is descibed on MSDN: natvis tries to parse the first entry. That one is checking if _ptr->__vfptr is not nullptr. For your IStreamManager this can be parsed and evaluates to true, so the first entry is used, the object itself is taken and expanded. If the condition on the first entry fails to parse because there is no __vfptr then the first entry is not used and the second entry is used. That one is doing just what you have now in your existing code.


Gear: Stats and rating

Question: I didn't find a good/exact explanation on this so:

How much rating (e.g. crit rating/penetration rating) is needed for 1% of the stat?
How much hit rating is required? (cap for pve/pvp?)
How does attack/heal rating influence my performance?
How is combat power exactly calculated out of my stats?
Is there a cap on certain stats? (e.g. crit)

Since I like to max out a game, I like to be able to calculate gear and optimal stats. (e.g. balance between crit and crit power for maximum dps) But for doing this I need to know how the game works/calculates things.
Comment: @JerryRox Seems a little premature on the bounty award; there's been no time to vet accuracy or even utility.
Comment: oops... I guess I still have to learn a lot on this website! ^^
Comment: I read somewhere that the cap was 440?
Comment: @Lyrion On which stat(s)? Could you please try to provide a source?
Comment: My guess is crit, pen and hit. But not sure, ill go look for it tonight.
Comment: did the answer below answer your question?
Answer: It seems that a site that explains the stats themselves can be found here. It'll just allow people to see full details on them.

How much rating (e.g. crit rating/penetration rating) is needed for 1% of the stat?

As far as I could tell via forum entries and blog posts the answer varies. But there is a forum post right here that says

Amount of Rating needed to reduce damage by 1% is between 23 and 35 in this sample.

This seems to be the same throughout all stats.

I thought that this may be of some assistance when it comes to damage. Lower down it explains what can increase your damage. The entire thread is all about healing and balancing that with attacks. It also explains how to glyph (which is handy).

Is there a cap on certain stats? (e.g. crit)?

Lyrion said that the cap for critical/penetration and hit was 440. This is false. This forum shows users who have experimented and have found that there is actually no cap.

How is combat power exactly calculated out of my stats?

Unfortunately there is no finite answer in this. After searching on this topic for about an hour. This is what I have concluded: Your stats are extremely loosely related to the 23-35 points above.

How much hit rating is required? (cap for pve/pvp?)

This is your last question. However it was tricky to answer. The forums are vague with this, always seeming to answer it but actually switching to a new question. But in here scroll down to look at sorrah's answer. I think it'll somewhat explain the hit rating requirements.

All in all your question can still be expanded upon. Since this exceeds the limit of characters possible in a comment I made it an answer. Hope this helps.

Gear: Stats and rating


Filter my cards by organization?

Question: Is there a way to filter all my cards from a single organization?
Perhaps I have to make a second account one for work another for home, and so on..
If you already solve this, any clue are welcome
Answer: You might need to carefully name your boards but you do not have to create a second Trello account to get close to what you want.
To sort all your cards by organization click your user icon in the top-right corner of the page (to the right of Boards) and select "Cards", they should then be grouped by organization then board.  So far, I have not found a way to filter by just one organization.
Your board names are sorted alphabetically so name them accordingly. "AAA - My First Board" and "ZZZ - My Last Board". (optionally) preceding names with "AAA", "ZZZ" or anything forces a sort order no matter the name of the board.
You may not be able to see this in action until you setup your boards into separate organizations.  If so...
First, create your Organizations.
  One for work, another for home and any others you may need (Name them however you want).  To do this click your user icon in the top-right corner, select "Organizations..." then "New Organization..."
Second, create boards for your organizations.
  Click your icon, then Boards.  Find the organization and click on "New Board".  To assign an existing Board to an organization select Board Options then "Settings..." and "Change Organization...".  Keep in mind that a Board can be just a single project and you can have as many boards as you want, however, a board can only be part of one organization.
Next, create Cards for your boards in the normal way.
Now, going to "Cards" will show you all cards grouped by organization then by board.  The organization name should now appear to the right of each board name.

Filter my cards by organization?


Live edge slab "dent" protection

Question: I am finishing a live edge slab for a bathroom sink vanity countertop. The slab is absolutely perfect for the space, but had a chunk broken on the side of it. I sanded the chunk out as much as I can, and feathered in the depression so that it blends in pretty well. However, there's still a slightly visible dent in the slab. I'd rather not keep sanding it out, so that the countertop doesn't have an even deeper depression. However, I'm looking for suggestions on how to finish it off (epoxy seal? Just finish with the Rubio monocoat as is? A creative solution I haven't thought of?) thanks!
Comment: Hi, welcome to StackExchange. If you're going to be using Rubio Monocoat you need to respect how the product works with the wood, and being applied directly to bare wood is a requirement so that rules out sealing in advance with an epoxy.
Comment: You could also have replaced the damaged part with a scab or patch, which can often add to the charm of a piece that is intended to show off wood and joinery.
Comment: Consider the dent part of the character of the piece and roll with that?
Answer: You might be able to repair the dent with the steam technique.  Get a clothes iron and place a wet towel over the dent and use the iron to heat up the towel and generate hot water and steam.  Ideally the dented wood fibers expand and fill out the dent again.  Once it's dry the dent won't return.

Live edge slab “dent” protection


QGIS SpatiaLite layer does not display

Question: I am having a problem in QGIS with some layers failing to display on the map canvas.
I am trying to learn about QGIS by working through the Training Manual found on docs.qgis.org. I am running version 3.16.1 under Linux Mint 19.3. I installed the Flatpak version of QGIS  using the Linux Mint software manager. Several months ago I downloaded the training data that goes with the manual and worked on some of the exercises, and it all seemed to work well. But recently when I looked at the project the layer that was imported from a SpatiaLite database, called landuse, no longer displays on the canvas even though the layer is check-marked in the layers list. When I look at the attribute table for this layer and select Zoom to Feature on a record it zooms in but does not display the feature. When I select Flash Feature it does flash. Another layer, called roads, which is from a Geopackage database, also will no longer display on the canvas. Other layers which were imported as shapefiles are displayed. I tried downloading the training data again and connected the SpatiaLite and Geopackage files under new names. I imported the layers into a new project but the landuse layer (SpatiaLite) still does not display. The roads layer (Geopackage) does display but if I zoom in it disappears and will re-appear if I go to full zoom. Does anyone have any ideas to fix this?
Answer: It can be hard to debug these sorts of issues for an experienced user, even more so to someone new to GIS.
You have already tried re-importing the data as a new layer. That is a good thing to have checked first.
Other things I would try:

verify the layer CRS is correct

verify the layer is not covered on top by another layer blocking it (as a quick test, try unchecking all other layers)

verify you don't have scale-based rendering on for the layer, with rendering turned off at the scales you are using

in the layer symbology, temporarily add (with the + icon at right) an extremely plain vanilla additional symbol layer of whatever garish colour symbol/line/polygon fill strikes your fancy. The purpose is to make sure your current symbology (which by the way could be being imported as a default style from the database storing the data, if you munged something up) doesn't have some crazy conditionals or data-driven settings that you're not noticing but are hiding it in your instance. (I once spent a frustrating hour debugging a disappearing layer, where it turned out I had turned on data-driven colouring with an expression based on another field I had unwittingly renamed.)
Comment: Thank you for your suggestions. Everything looks good for points 1, 2, and 3. Regarding point 4, adding another symbol layer did not help. If all else fails, would it be worth trying to uninstall QGIS and re-install it? I could then rebuild things  on a "clean slate".
Answer: I have this same exact issue. I just downloaded QGIS and training data today, same system configurations (linux, flatpack, etc).
Update I just got the spatialite data to render. It seemed QGIS wasn't mapping the geometry field correctly. I have not figured out how to correct the GeoPackage data.

Right click on layer
Select Update SQL
On the bottom right, map the geometry field

Second update: I re-extracted the data, and then the GeoPackage data rendered correctly. I have no idea why this would change the rendering result, but yet it did.
Comment: Thank you very much, that worked for the SpatiaLite layer! The Geopackage layer (roads) will display if I zoom out enough that the entire layer is within the map area. If I zoom in or pan so that any piece is outside the map area it all disappears.
Answer: I think you have different installation of QGIS. Flatpack version has a problem.
Warning 6: driver SQLite does not support creation option SPATIALITE
ERROR 6: OGR was built without libspatialite support
... sorry, creating/writing any SpatiaLite DB is unsupported

Answer: In case anyone comes across this problem, and is searching for a different answer, ensure your X and Y data you're passing to SpatiaLite is actually enter as Real or Integer.
df_points.to_sql('db_points',con,if_exists='replace',index=False, dtype={'line_station': 'INTEGER',"Line": 'INTEGER', "Station": 'INTEGER', "X": 'REAL', "Y": 'REAL', "Elevation": 'REAL'})

Hope that saves someone some hair.

QGIS SpatiaLite layer does not display


Retrieving the password of a user with php api

Question: I am preparing a form on an external page using PHP. Is there a way to check the password entered in that form with the one in Marketing cloud? I used "AccountUser" object to get the password but it didn't show the password.
Answer: Pretty much all password based APIs will not return the value of the password that the user entered. Instead they store an encrypted version of the password such as a salted hash and when a login attempt is made they apply the same algorithm to the entered password and see if the result matches the stored value.
One reason for this is to stop someone who has hacked in from just being able to grab the passwords and start pretending to be real users.
Bottom line is that you should leave the job of checking the password to the system that manages the passwords i.e. make an API call to it to check or get it to present the authentication UI e.g. via OAUTH. (Not sure what the appropriate choice is for Marketing Cloud.)
Comment: Hi, I have used OAuth to allow user to login via Marketing Cloud but now the problem is I don't know how to because I need client ID and Password to execute processes via PHP.
Comment: @SelimSevim You can normally use the access token provided via OAUTH in APIs. Suggest you add a new question identifying the specific PHP/library you are using and the specific problem.


Is it possible to get malware through an incoming video/audio stream? (e.g. Omegle, Skype etc.)

Question: Is it possible for incoming video/audio streams to contain malware through exploits in the transfer of the video/audio?
Answer: It could be possible in some cases.
For example, imagine that the videoconferencing software has a vulnerability into the file format parser (E.g. buffer overflow)... then it could be exploited by a remote attacker.
Look at VLC for example http://www.cvedetails.com/vulnerability-list/vendor_id-5842/opec-1/Videolan.html
Comment: Awesome, would it be possible for specifically Omegle to do this?
Comment: It's potentially possible for any software. From a security perspective it's mainly concerning for remote user input whether that would be direct or indirect to cause a remote buffer overflow this happens when the programmer doesn't valid the user input very well. So, to answer your question yes it's possible. If you watch the following videos it will explain what buffer overflows are and how they are performed and so on in much more detail which will give you a better understanding: http://www.securitytube.net/video/231
Comment: As for Omegle I believe it uses flash to display its video stream so, if an attacker finds a vulnerability in the version of flash that your machine is running he/she can easily send over something to trigger and/or exploit that vulnerability.
This sort of attack is known to happen from time to time [just look here...](http://www.cvedetails.com/vulnerability-list/vendor_id-53/product_id-6761/Adobe-Flash-Player.html)
Also note that this can happen with pretty much any site that plays audio/video streams. (That's why one shouldn't browse sketchy Chinese sites looking for "entertainment"... ;)
Answer: Yes, it is very possible to  gain remote code execution (RCE) via programs such as Skype. For example, there was a notorious exploit in the FreePBX client provided with the Elastix 2.2 platform which triggered by merely accepting a call, as can be seen here on youtube, which gives full code exeuction.
Also looking through www.exploit-db.com shows you that technologies like Skype have used or still make use of HTTP based protocols for some of their features, which have also previously been exploited succesfully.
As for Omegle: @Wolfer already correctly identified that it uses flash which has been known to have more than its fair share of bugs that have been succesfully used to create exploits, and any future ones will no doubt also have an effect on Omegle.


Any bright ideas or plugins to recommend? Wordpress

Question: I need to make a WP MU so only subscribers that is given access can view certain categories and this is to be different subscribers for different categories (or posts)( i mean to be picked up which can for every category or post).
For example:
-Category 1 can be viewed by:
*subscriber 2
*subscriber 6
*subscriber 11
-Category 2 can be viewed by:
*subscriber 11
*subscriber 13
Hope you got what I mean.
:) Thanks in advance, I'm thinking this for a week now but can't put my head around it.
Answer: Try this: http://www.s2member.com/


Greening The Sahara

Question: Would it be possible to "green" the Saharan desert, given near future technology If so what things might have to be done, what kind of plants or bio engineered plants and animals would be introduced? Would dropping chunks of comets from orbit work to provide rain?
Comment: Doesn't sound like worldbuilding to me.  You probably ought to start your own research by reading [Wikipedia's page on desertification](https://en.wikipedia.org/wiki/Desertification).
Comment: Just to be clear... are you wanting to green the ENTIRE Sahara? or just part of it?
Comment: An old friend of mine once said, "given enough time and money anything is possible."  Frankly, producing highly efficient desalination would be much more economical than redirecting (and slowing down... really slowing down) comets and simply adding water will solve the problem if you have enough time to wait for the plants to grow on their own.  What are your constraints?  What is the tech level? time requirement? end-goal of the effort?  Must animal life be preserved? Are we ignoring political issues? Can we recraft the landscape to form new lakes and rivers? Etc.
Comment: Relevant video suggesting this as a means of carbon capture: https://www.youtube.com/watch?v=lfo8XHGFAIQ
TLDW: Desalination plants used to water eucalyptus trees.
Answer: Dropping chunks of comets is a bit extreme, but a source of water is much closer at hand: the Nile. The Aswan High Dam will eventually directly or indirectly cause water to spill into the Qattara Depression, creating an even greater artificial lake than Lake Nasser.

Qattara Depression Project
The Qattara Depression Project as originally envisioned would have water flow from the Mediterranean Sea into the depression, but using fresh water from the Nile would eliminate many issues cause by using salt water for the project. The water flowing from the Nile into the depression can be harnessed for hydro power, for industry or to desalinate sea water from the Mediterranean Sea, and the large area of the new lake would absorb solar energy, changing the micro climate, as well as evaporating and creating the basis for more rain in the region.
A different source of water would be to dam the Congo river (one of the various unlikely proposals going with "Atlantropa project"

Damming the Congo and creating inland seas. What could possibly go wrong....
Longer term (centuries), water will seep from the bottom of the new lake, and charge underground aquifers over a much larger area. Current oasis will expand, and older ones which had dried up will be revived, providing the nuclei for further greening, even without human intervention.
Some things that people can do to speed up the process is to plant fast growing grasses and other vegetation along the edges where lakes or oasis are growing to stabilize the soil, and manage the introduction of microfauna (bacteria and fungi) which will further bond to the particles of sand and help speed up the conversion process into new soil.
Either of these projects is geoengineering on an unprecedented scale, and the possibility of unanticipated effects overwhelming the initial goals of the project are about 100% (the biggest variable is what the effects of the new micro climate over northern Africa will actually be). Of the two, the Qattara Depression Project is likely more feasible (for certain definitions of feasible), although probably still outside the scale and scope of human engineering projects for a while yet.
Comment: Ooo, I've never heard of the The Qattara Depression Project before.  Wouldn't that just create another Salton Sea?
Comment: Maybe the Aral Sea is a more apt comparison, since there should be a constant influx of water to replace the evaporated water. With proper management and active control, the system should achieve some sort of homeostasis .
Comment: True, which illustrates how difficult it is to communicate complex ideas in this format. I understand there are several projects to revive the Aral sea, including increasing the input via agricultural improvements upstream, and using dams across the seabed to prioritize where the water is stored.
Comment: Heh, you mean the Aral Sea *used to be* a more apt comparison.  Not much of an influx anymore.
Answer: This is one of many very dangerous suggestions put forward by "geoengineering" enthusiasts.  As Mark Olson notes, the Sahara was indeed once a lot greener than it is today.  In fact, it's still growing!  Terrifying, right?  There are efforts to stop desertification (as Tim B II discusses), usually involving planting very hardy vegetation in order to stop erosion and create the necessary ecosystem functions to retain water.  Interestingly enough, however, a plan to completely forest the Sahara, as you propose, could lead to the destruction of the Amazon rainforest, which is fertilized by 22,000 tons of phosphorus blown from the north African desert every year, alllll the way across the Atlantic!
Answer: While I agree with Mark's answer, it should be noted that there are companies Converting the Sahara to farmland now, as we speak. Also, both Israel and Ethiopia have water management plans in place aimed directly at converting desert areas into arable land for farming purposes. None of these 3 real world modern examples have used comets, but they have used water in ways that preserve and reuse this precious resource.
This (ultimately) is the way to change a desert; the key is water. Deserts look like they do because there's no water there. Add water, and over time the sand becomes soil and plants begin their slow march into the space. Of course, we can accelerate that process, but the secret is and has always been water. Whether you divert existing fresh water sources, or desalinate existing seawater, once you have the resource, you can use it at the periphery of the desert and let the vegetation solve the problem for you if you wish.
Accelerating that natural process is more complicated of course because plants as they grow, die and decay add nutrients to the soil that allow for the next generation to grow faster and more reliably. Acceleration means providing those nutrients faster, and probably seeing the sand with topsoil as well so that it can be used by plants faster, but essentially vegetation on Earth is prolific and will solve the problem for you in time, given enough water.
When you think about it, that makes perfect sense; plants are constantly being eaten by other things; if they weren't this prolific, they wouldn't survive. So, in that sense, the fact that they form the primary food source for us all, even feeding the animals we eat, means that they are evolved to grow as voraciously as possible in ideal circumstances. Water just provides that ideal circumstance.
Answer: The Sahara was substantially greener just a few thousand years ago -- North Africa was a breadbasket for the Romans. And a few thousand years before that was the wonderfully named Neolithic Subpluvial when it was green and supported a rich assemblage of life.
So, add water and a bit of time to recreate soil and you have a Green Sahara.
I doubt that moving comets is optimal. I strongly suspect that pumping large amounts water from the Mediterranean into depressions and creating large (salt) lakes would by evaporation add enough water to the atmosphere to increase rainfall.
Since some theorize that the Sahara was formed by neolithic herders moving in and converting the vegetation to scrub which then started a vicious cycle leading to desert, it's possibly that careful re-vegetation of the region using desalinated water might produce a stable wetter climate.
Answer: Combination of using seawater to dissipate waste heat from a nuclear plant and filling the QD
I would like to add that:

electricity is generated when Mediterranean seawater (Mw) goes
downwards from the Sea towards the QD.
The Mw enters the nuclear plant and becomes heated.
With the heat though, can water desalination happens in a factory complex next to the nuclear plant. So magnesium, calcium, potassium are extracted. Chloride acts as the spectator ion.
The Hypersalty Mw with sodium chloride returns for another cycle of
taking waste heat from the nuclear plant. The Hypersalty Mw returns to the Med.
The desalinated Mw also return for another cycle of taking waste
hear from the nuclear plant.
The desalinated but heated Mw goes downward into the QD, giving away
energy for electricity generation.
Cotton plantation could takes place using the potassium and magnesium
minerals and thus reduce the reliance on the Nile.

In total, three cooling cycles per a batch of waste heat for water desalination and electricity generation.

Greening The Sahara


Is it possible for Wireshark to drop packets purposely?

Question: I would like to test something like VoIP. I would like to test with some "artificial packet loss". Is Wireshark able to do this? Or is there any good solutions?
Answer: You can use tools like WANEM to simulate packet loss. It's a Live-CD, so you can put it on a system between your server & clients.
Answer: WANEM as mentioned is a good tool. If you're doing on Linux you can also play with the buffer queues etc, check out this page which has many answer to this questions already including netem and queue examples;
Also, you can use tools like iperf/jperf to saturate a link.
You can also use iptables to drop packets, like this.


How to convert a timestamp field into a date field?

Question: Is there a way to convert the data of a timestamp field into a regular date field in Drupal 8? preferably without coding or making a new module.
Answer: Export/import with Feeds
Feeds module can help to export the existing Timestamp field data and import it into a new Date field.
Feeds Tamper to convert from timestamp to ISO date format
I'm not sure if you can export timestamp into the ISO format directly. If you can't, then you may convert the timestamp to ISO format externally once you have it in a CSV file for example, or you use Feeds Tamper module to convert it during import.
Unix timestamp to Date is on the Feeds Tamper plugin list.
Setting up Feeds can take patience and time, so arm yourself with those, backup everything before starting to meddle with it, and test everything on a local/dev instance. (This always applies, but I find it's good to remind when dealing with Feeds.)
After you have the Date field correctly filled with data, you'll want to delete the Timestamp field.
Delete old Timestamp field
To do that you need to delete the Timestamp data and then the field from your system. You won't be able to delete the field that has some data in it.
To delete the Timestamp data you can use another Feeds import to update the nodes and make that field empty.
You could also delete the data with the help of Views Bulk Operations (VBO) or work directly on the database through some other SQL tool but that is probably out of scope here.
When the Timestamp field is empty you can delete it from your content type through the usual Drupal interface.


ECU tuning exhaust - why?

Question: When a sports exhaust is fitted to a car apparently a re-tune of the ECU is required.  For a simple example consider a regular unmodified normally aspirated petrol car which then has a sports exhaust fitted to allow higher rate of air flow.  I've read that an ECU tune is required to get the best performance.  In this case which maps does the tuner change ?
Comment: As a side note, even if you don't get the ECU tuned, performance will change slightly as the ECU can alter timing map and other related variables within a narrow range.
Answer: Timing, fuel delivery ie what is called the characteristic map.
If you want to get to grips with this, read up on the early engine controls such as the J and K systems by Bosch - these were simpler than the newest generation used now and may be easier to understand.

ECU tuning exhaust - why?


How do I solve this OpenNi dependency error in PCL when using the Kinect?

Question: Although I've just signed up for Stackoverflow, I've used answers.ros.org, pcl-users.org, and other similar sites.  I'll try to give as much information as possible because although similar problems come up in Google searches I cannot find an answer to this.
I'm running Ubuntu 12.04 and I've installed PCL 1.7 via their set of instructions here: http:// pointclouds.org/downloads/linux.html
Following the tutorials I was able to get the "reader" and "writer" sample programs to work with the sample PCD's they give.  I was also able to successfully use cmake to compile a more advanced program: http://pointclouds.org/documentation/tutorials/normal_distributions_transform.php#normal-distributions-transform
The problem begins whenever I try to make the iograbber or any other visualization programs that involve the Kinect.  This is specifically the one I really want to use: http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber  Repeatedly, without fail, this has always been the warning I encounter when using cmake:
-- checking for module 'openni-dev'
-- package 'openni-dev' not found
-- Could NOT find openni (missing:  OPENNI_INCLUDE_DIRS)
** WARNING ** io features related to openni will be disabled
It gives this warning several times in a row related to various components checking for it.  Now you might say, "silly user, why don't you simply install openni-dev?"
Well when I initially did it with sudo apt-get install -y openni-dev (notice the -y which I soon learned about) it deleted most of my ROS/PCL files.  Thread is here: http:// www.pcl-users.org/How-can-I-get-PCD-files-from-a-streaming-Kinect-td4033721.html  It broke some packages and long story short I found out about aptitude and eventually I got myself back to square 1.
The thing is, I'm fairly sure I have openni 1.5.4 installed but somehow it isn't being found. When I go to my usr/lib folder it only shows an OpenNI2 folder, and not an OpenNI folder.  I know there's a lot of issues with openni-dev popping up for PCL and ROS so I hope this answer will be able to help others as well. Before you ask, I'm copying/pasting the CMakeLists and C++ files exactly as I find it.  I don't have a lot of programming experience so I hope I'm not missing something obvious.
Comment: May you first want to make really sure that OpenNI (1.x) is really installed by searching (e.g. with `locate` or `find`) for the lib files (e.g. `libOpenNI.so`) and the include files (e.g. `XnOpenNI.h`).
Answer: If you use kinect v2, there's no OpenNI support.
So you can use this grabber:https://github.com/UnaNancyOwen/KinectGrabber/tree/Kinect2Grabber


Moving code from Git Repository to sandbox using Ant

Question: We're trying to implement source control using GitLab and Jenkins. I know how to merge code between two branches in Gitlab. That has to trigger a job in Jenkins to deploy changes from the remote branch to its associated salesforce sandbox. Can we using Ant Script for that? Right now ant script can only move changes between two sandboxes but not between a repository and sandbox. Any suggestions would be highly appreciated.
Answer: I don't know what GitLab does or does not add to the process, but this answer assumes there is a Git repository somewhere...
Jenkins supports Git in its "Source Code Management" options and so a Jenkins build can be kicked off when there is a change in Git for a particular branch. Jenkins checks the code out to its local workspace (a folder) and then an Ant script can invoke the sf:deploy Force.com Migration Tool to push the code from that workspace into e.g. a sandbox and run the tests.


How to distinguish between appreciation and inflation?

Question: Is there a way to differentiate between the appreciation of an asset and the devaluation of the currency it is denominated in (inflation)? I know I could look at conventional inflation measures (like CPI) and compare against the performance of the asset in question, but one could argue certain baskets of 'things' haven't been impacted by inflation at the same rate because of lower/higher money velocity. I could compare asset price against increase in money supply, but this seems rudimentary and would imply inflation is 1:1 correlated with increased money supply and that doesn't sound right. Is there a sure-fire way to distinguish between the two for a given asset?
Answer: Inflation is a general up trend in price when value remains unchanged. Hence "the same thing" suddenly costs more.
Appreciation is a bona fide increase in value. This tends to also increase the price that the market will pay.
Thus put, the difference is clear: value_final - value_initial = appreciation and appreciation + inflation = price_final - price_initial The problem of course is that it is very hard to accurately determine value. There are ways - but ultimately, almost all measures of value are more or less contaminated by inflation.
You can go the other way and simply measure the inflation, and then work back to get appreciation. This is somewhat circular in that inflation is defined in relation to value. This is where things like CPI come in - the premise is that the benchmark is either inherently unlikely to appreciate much, or the appreciation happens to be very predictable. Of course, it is debatable whether you can assert that there is any asset which does not appreciate or depreciate over a given time. But if you trust the government's CPI (or any other's source's), then you can use it to infer appreciation, and the appreciation will be accurate to the extent that the CPI is accurate.
So let's say:

CPI was 2% over last 10 years
You bought a house 10 years ago for 200k
The house is now 300k

You have a price difference of 100k or 50%. The inflation alone would have resulted in 244k, so we can consider the 56k to be appreciation.
Comment: nicely done! Upvote
Comment: Shouldn't your example use the housing CPI instead of the general CPI?
Comment: @Flux: No, at least IMHO.  Housing CPI is going to be affected by factors other than inflation, e.g. the area you live in having become a hot housing market.
Comment: Is CPI an accurate measure of inflation? You said "if you trust the government's CPI"...
Comment: I am sorry, I just can't agree with this answer.  The first sentence would be something like me stating blankly "Dark matter is sterile neutrinos" (of course, nobody has a clue what dark matter is, and it's actively debated).
Comment: Flux - I'd say no. I like this answer. If over some period of time inflation was 50% but homes on average doubled, would you ignore it and say that your house only kept up with other houses?
Comment: @Flux Maybe, but I don't think it matters for this question which exact measure of inflation is used.
Comment: @Runeaway3 My premise is that there is no perfectly accurate measure of inflation, but the government's CPI is usually considered pretty close.
Comment: @Fattie Wouldn't it be more like stating "dark matter is a gravitational signature reminiscent of matter without a corresponding electromagnetic signal"?
Answer:
I know I could look at conventional inflation measures (like CPI) and compare against the performance of the asset in question, but one could argue certain baskets of 'things' haven't been impacted by inflation at the same rate because of lower/higher money velocity

Your basic approach is correct. You take measured inflation and subtract it from your gains. The problem is measuring inflation. The problem you have spotted is that measuring some basked of things is not necessarily measuring "true inflation", but this does not have anything to do with money velocity. The problem is based on a much simpler issue: inflation for different things is different.
Let's say the price for gas is decreasing but the price for TVs is increasing. How do you weigh this? You can build some basket, average things out and postulate this as the official inflation rate. But this is just an approximation and it will inevitable be different from the inflation everybody feels. Even worse, it may miss entire categories, e.g. in some countries only rent (=pretty sticky prices) is counted towards inflation but not self-owned homes (which are a lot more volatile in price). How do you properly account for categories where prices are falling fast like consumer electronics? After all, something comparable to the flagship phone of today will be available for like 200$ in the pretty near future. Additionally there is the problem of actually measuring prices. How do you treat items that are currently on sale? What is the price of a flight with airlines changing prices all the time? (Bonus question: how do you measure the price of a service if that is unavailable during lockdown times?) All of these issues make CPI a not so suited measure for inflation.
A probably better way to judge inflation over long time periods is to compare your asset to incomes. After all, no matter what we count or not, if things get more expensive overall, people will demand higher wages. Over the long run, this should roughly be on par with the actual inflation
Comment: I understand your points here, but I am having a bit of issue with your statement saying 'it has nothing to do with money velocity'. While I agree that the overarching issue is that different things inflate differently, could you not argue that varying money velocity is at least partly a contributor to this phenomenon?
Comment: Well...money velocity is a concept of a world of cash but is pretty blurry as a concept in a world of electronic payment and fractional banking. And even if we ignore this complication and assume an all-cash economy does higher velocity mean that people can afford higher prices? No, because the money is just circulating faster. So velocity is at best a symptom of inflation (because people do not want to hold fastly depreciating cash) but not a cause.
Answer: The simple answer is "no".
Concepts like inflation, devaluation etc are debated heavily among "economists". There's not even close to an agreed definition.
Nobody has the slightest clue how fiat money supply affects inflation-like concepts, and nobody even vaguely agrees on basics like what money supply is.
Your question is essentially saying "Explain the greatest and most heavily debated monetary-economic-political issue of the last 500 years" - !
(Just one point, note that inflation does not exist, it's just talking point. It's not quantative. If you're sports fan, some facts are "The bucs won the most recent superbowl" and "the current record marathon is 2:01:39".  In contrast you know how the newspapers will have articles about "MVP"?  ie some guys write down their idea on who is the "MVP". Maybe they have a vote amongst sports writers. Inflation is like that - "talk". Various newspapers, boards, universities etc have a few guys sit down and decide on what "inflation" was in country X last year.  (You can pick sundry completely different methodologies, and choose a newspaper you like.) So what?  If a few guys at The Economist say "Inflation in France last year was: 3.343%" who cares?)
Comment: There's definitely plenty to argue about regarding inflation, but I think you overstate the level of uncertainty around it. Arguing about what is in the market basket is a far cry from saying that the whole concept doesn't make sense. And saying "inflation doesn't exist" just isn't true. It is absolutely real, even if difficult to measure precisely and open to debate regarding the mechanisms.


Java unhandled exception disappears

Question: Suppose there is a class such that:
public class Magic {

public static void main(String[] args){
    boolean[] val = new boolean[0];
    paradox(val);
}

private static boolean paradox(boolean[] arg) {
    Container container = null;
    try {
        container = Container.getContainer(arg[0]);
        return container.value;
    } catch (UnsupportedOperationException e) {
        e.printStackTrace();
        return false;
    } finally {
        try {
            container.sayHi();
        } catch (UnsupportedOperationException e) {
            e.printStackTrace();
        }
    }
}

private static class Container{
    private boolean value;

    private Container(boolean value){
        this.value = value;
    }

    private static Container getContainer(boolean value) throws UnsupportedOperationException{
        return new Container(value);
    }

    private void sayHi(){
        System.out.println("Hi!");
    }
}
}

If this code is executed, there is a null pointer thrown on line with
container.sayHi();

container should, in fact, be null. Before the assignment can complete there is an ArrayIndexOutOfBoundException thrown when we call getContainer(). However, what happens to the ArrayIndexOutOfBoundException? Why do we go into finally{} after an unhandled exception?
edit: poor phrasing. question is why we go directly into finally{}. And what happens to ArrayIndexOutOfBoundException
Answer:
Why do we go into finally{} after an unhandled exception?

We always go to finally after a block exits (successfully, after an exception handler, or after an unhandled exception). That's exactly what finally is for: a place to put code that will be run no matter what.

However, what happens to the ArrayIndexOutOfBoundException?

If you encounter a second exception in an exception handler or a finally block, then that second exception will be propagated and the original exception will be hidden.
If you want to preserve the original exception, you can manually attach it to the new exception via Throwable#addSuppressed (or the other way around, re-throw the original exception and attach the new one as suppressed).
Comment: the problem is how to access the original exception in `finally`
Comment: That's true. Here's how it is implemented for the auto-generated finally blocks of the `try-with-resources` construct: http://stackoverflow.com/questions/24181489/why-does-java-not-support-retrieval-of-exceptions-from-try-catch-lost-when-an-ex?rq=1 First rule of business is probably to make sure `finally` does not raise any more exceptions in the first place.
Answer: There is a simple rule in Java: finally is always called.1
So what happens is this:
container = Container.getContainer(arg[0]);

This throws an ArrayIndexOutOfBoundException, which is uncaught. Before the exception bubbles, finally is called.
container.sayHi();

container == null so a NullPointerException is thrown, this shadows the original exception. As per the JLS §14.20.2

If execution of the try block completes abruptly because of a throw of a value V, then there is a choice

... then

If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and the throw of value V is discarded and forgotten).

emphasis mine
1: except when System.exit is called or some other rare cirumstances.
Answer: Another surprise you may get when doing control flow operations inside finally block :
public static void main(String[] args) {
    System.out.println(badFunction());
}

private static String badFunction() {
    try {
        throw new RuntimeException("Catch it!");
    } finally {
        return "Exception disappears";
    }
}

Comment: yes, `finally{}` should always complete uneventfully. (except for throwing Error which can never be prevented)

Java unhandled exception disappears


How to generate whole Pageable Object with Swagger Codegen instead of each properties inside it?

Question: I have an API to retrive all products with Paging and Sorting functions as follow:
@ApiImplicitParams({
        @ApiImplicitParam(name = "page", dataType = "integer", paramType = "query", value = "The page number that should be returned. Default is 0."),
        @ApiImplicitParam(name = "size", dataType = "integer", paramType = "query", value = "How many items the page should have. Default is 20."),
        @ApiImplicitParam(name = "sort", allowMultiple = true, dataType = "string", paramType = "query", value = "Sorting order, e.g. asc or desc. Default is asc")})
public ResponseEntity<Product[]> getAllProducts(Pageable pageable) {}

And then I use Codegen to generate Client API but the problem here is the method's signature that it generated is not the one that I am expecting:
public List<Product> getAllProductsUsingGET(Object page, Object size, List<String> sort){}

What I would like to have here is getAllProductsUsingGET(Pageable pageable)
Did I make some mistake with the configuration? Can anyone give me some hint how to achieve only pageable as parameter instead of each single property like that? Thank you very much!
Answer: you are defining the API implicit parameters to include exactly those 3 parameters. Nonetheless, I don't think the final API should contain signatures that include Pageable params as these are dependency of Spring and you don't want your "connector" API to bring Spring dependencies attached.


Is there a standard system example for writing papers which introduce a newly developed programming language?

Question: I am writing a paper that describes a programming language that I am developing as part of my PhD. I think that writing the paper using an example can greatly improve how the paper is understood. Is there a "standard" example that is used in programming languages paper? A set of examples?
Comment: Not only there are some papers, there is a whole ACM interest group for that ([SIGPLAN](http://www.sigplan.org/)). On that page, you will find all the relevant conferences and journals on programming languages.

For example papers, browse the Proceedings of PLDI and POPL conferences. There is also OOPSLA (now called SPLASH) for more object-oriented stuff.
Comment: It depends, of course, on what you're trying to illustrate with your example. An example of a language is the untyped lambda calculus. Some algorithms and programs that are frequent examples are at [Rosetta Code](http://rosettacode.org).
If you want to know more about what's typical in computer science, you might ask at [Computer Science Stack Exchange](http://cs.stackexchange.com/) or, if the relevance is specific to professional researchers in theoretical CS,  [Theoretical Computer Science Stack Exchange](http://cstheory.stackexchange.com/).
Comment: It depends on what you want to show. Hello world is usually the minimum example, then Fibonacci for recursion, prime numbers in [2,100] for loops, etc. As you move to more fancy features the standardization fades (AFAIK, hopefully I'm wrong). More than focusing on a standard, I'd focus on an example that shows clearly the strengths of your language or the motivation. Finding the limitations or weaknesses is relatively easy, and frustrating, IMHO.
Answer: The biggest problem that you face when writing a programming language paper is explaining why the world needs another programming language, rather than a library or an API or something of the sort.
I would thus recommend skipping "standard" examples such as "Hello world" and recursive factorials entirely, and instead going straight to a set of minimal examples that illustrate the value of the new language.  Only in the case of a particularly extreme langauge will the standard examples be necessary to help understand the scientific concepts.
Note that documenting a programming language is an entirely different matter.
Answer: It would be helpful to learn about the specific strengths of your language, since good examples should illustrate its strengths (yes, this is more a meta-answer, but maybe exactly what you should be looking for).
The standard example is printing "Hello World"; everything else depends on the language and its features. E.g. you might want to demonstrate simple database queries, easy list processing, recursion, string manipulation, logic deduction, complex mathematics, ...


Finding which gear on my bike is closest to a single-gear bike

Question: I have a 21 speed bike, and I'm thinking of purchasing a 1 speed.  Does anyone know what gear on the 21 would be for a 1?  I'm trying to see how well my bike does on that gear in my area.  Thanks!
Comment: Learn how to count teeth on your sprockets and do the math.
Comment: You're testing different gear ratios on a multispeed bike to see what it would be like to ride that gearing on a singlespeed ?   That's really good thinking - excellent idea.   Do please test it both up and down the steepest grade you're likely to ride.
Comment: Single speeds don't have a single ratio. There is a variety of chainring and cog sizes that can provide different ratios to suit different riders and terrain.
Answer: We can't tell without more information about your gears.
However, you can figure it out for yourself quite easily, by looking at the ratio of chainring teeth to rear sprocket teeth on the single speed bike (the most common I've seen is 44/18 = 2.44).
Then you just need to figure out the size of your current bikes chainrings, the size of the sprockets on your current bike, and calculate all 21 gear ratios, and find which is closest to the single speed ratio.
If I had to guess, I would say it would most likely be equivalent to your middle chainring (39 teeth?) and somewhere near the third smallest rear sprocket (16 teeth?) because 39/16 = 44/18.
Of course, you can almost always pick and choose the gearing on a single speed bike, so realistically you yourself get to pick "what gear on the 21 would be for a 1".
Comment: Don't forget that the wheel size affects the effective gearing as well. If one bike has 700C/28"/29"and the other has 26" the difference is significant. Tyre width makes much less difference and can probably be ignored unless you're going very fat<->skinny.
Answer: There are numerous gear ratio calculation tools out there. Once you know which gears work best in your area, you can use these tools to find the ration you need. Something like this for example: http://www.bikecalc.com/gear_ratios
Or you can do it on paper :)
Comment: Well on the website you get a nice table with all the gears as well. But yeah
Comment: Yeah. Actually, I guess the point is that you can compute the gear ratio of the single-speed bike by dividing the two numbers, and then look in the table to find the closest match on the multi-speed bike, without having to calculate all the ratios that might be close. So I'm gonna nuke my comment and give you a +1 instead. :-)