What is a good NiMH charger?

Question: I have some (cheap/old?) batteries that I need charged.  The problem is, the chargers I have keep charging them until they get overcharged and lose their capacity.  I already ruined 4 1800mAh-batteries this way, and after inserting new batteries it seems to do the same thing to them.
However, this is a pretty advanced (used) charger, LaCrosse BC-900.
I wanted to try out Maha MX-9000, but I saw bad reviews of it on the internet (temperature sensing does not work, batteries leak when charged even more easily than on the BC-900).
I bought a $37 Chinese charger that charges via voltage cutoffs: that seems to work fine; however, I cannot test the capacity of the batteries.
I looked into getting a Hitec charger (X1 AC Plus seems like a decent one), but there you have to set cut-off voltages yourself: there is no "battery full" detection.
Obviously I am missing something.  Are there no chargers on the market that can, at least, do DeltaT "battery full" detection?  That's the main thing I need for my batteries, and I already spent quite a bit of money without results.
EDIT: I ended up trying both Maha and LaCrosse charger; the following is a review for those who might read this thread in the future.
Bottom line: the LaCrosse is hands down the better charger for >1000mAh-batteries if you do not know what you're doing.  On the other hand, if you are willing to sit there and monitor the batteries, then the Maha offers more versatility.  I read several reviews comparing the charger, but they all seemed biased one way or another (e.g. a person whose batteries leaked by Maha obviously was biased toward LaCrosse).  I thought I would do a fair comparison of both, to help me know which to use when.
So first, there are the purely cosmetical differences:

When inserting batteries into the LaCrosse, you have to set the charging amperage (up to 3 clicks), and also whether you want it to charge, discharge, cycle, or multicycle.  So 5 clicks is generally enough to set the process going.  On the other hand, using the Maha you have to start with the default setting, and scroll until you find the setting you want, click enter, for the charge mode, charge amperage, and discharge amperage.  Then you have to repeat this for every battery, since Maha not only does not remember the previously used settings, but it does not even remember the setting used for the previous battery.  This means over 50 clicks are usually required to start the process going.
Also, the Maha has this bright LED which cannot be turned off, and illuminated the whole room so bright I cannot sleep at night (since its charging takes more than a day).  Wonder how much electricity it takes.  But of course it can be covered.
The Maha detects internal resistance before charging.  It does not show it to you, but says "HIGH" if the battery should not be charged.  According to the manual, this only happens when the battery is not rechargeable or it has too high a voltage: something that you can see on the LaCrosse by yourself anyways.
Finally, the Maha displays the charging capacity for modes other than "Charge".  While this capacity does not get stored (so you have to be there when it finishes charging to see this capacity), at least you get to have an idea of how efficient charging is, and also approximately in how long it will finish. (note: charging capacity is 14-20% higher than the discharging capacity).

When deciding whether I want to get Maha or LaCrosse, I read the reviews which stated that Maha's "delta T detection for termination of charging" does not work.  This one person wrote that Maha charged his batteries so much that they leaked.  For this reason I decided to stick with the LaCrosse; but when the former did not work out, I decided to give the latter a try.  I would say his review is not far from the truth.  I inserted my batteries into Maha and went to church.  After coming back, it said charged.  Then I decided to switch slots to see if I got the same capacity charging them in reverse slots (i.e. if the slots are balanced).  But, the Maha showed me both batteries were over 2.2 V (!)(exact voltage depending on the battery), and then showed "HIGH", i.e., the voltage is too high for it to do anything to the batteries.  OK, Maha, but why in the world would you charge them to that voltage in the first place?  Isn't there like a voltage cutoff?  Apparently it was waiting for the negative Delta T or Delta V, and it just didn't happen because the batteries are Chinese quality.  The manual says that if this detection is incorrect, the "discharge" mode does not do resistance detection, and so I can discharge the battery therewith first, and then run my charge-discharge-charge cycle.  No thanks, Maha: I think I will leave these batteries for the next charger I'll test.
On the other hand, the Maha has this functionality called break-in mode.  This mode was designed for making the batteries with slightly higher capacity remember only a certain amount of it, to make sure all batteries would get about the same (albeit lower) capacity, to prevent reverse charging when inserting many batteries in series.  However, the way it specifies it does it is, apply a current equal to 0.1C for 16 hours (and more).  Since battery capacity can be chosen from 500mA and higher (in 100mA increments), effectively what this means is, you can get to choose the charging amperage in *10*mA-increments, starting at 50mA-- if you are willing to sit there and wait for it to hit your desired voltage.  (which in and of itself is pretty annoying, since it takes several clicks [read: physical access to it, no more using the socket under the bed] and about 40 sec of waiting to see the voltage, since every time you click it restarts at MAh, and Volts is last.)  But, if you have low-capacity batteries (say 500mAh or lower) and have an idea of the cutoff voltage, then this is worth it: since this is in stark contrast to the LaCrosse, where no matter how hard you try-- you cannot charge it slower than 200mA.
So those were the highlights; now, I will compare its charging capabilities one at a time:

Charge/discharge:  Maha gives the option to charge from 200mA to 2000mA, in 100-mA increments.  LaCrosse only gives the choices 200mA, 500mA, and 100mA (a few more choices depending on the model).  The other limitation in LaCrosse is, the discharge rate has to be half the charge rate, and you have to set the maximum rate that will be used within 7 seconds or so of inserting the batteries.
On the other hand, Maha displays the capacity, amperage, time, and volts in 2-second increments, and moves from battery to battery.  So if you would like to monitor just the volts, that is not possible; also, staying just on one battery is not possible.  You can click a button to choose which battery you would like to see, but you have to wait until it displays the number you want (e.g. voltage); also, after displaying that number it cycles on to the next battery, and you have to click thrice to choose your battery again.  The maha displays all 4 batteris' status, and you can choose which number to see and to stay on.
Cycle: The LaCrosse cycles Charge/Discharge until the battery stops gaining capacity (which would vary from battery to battery); the Maha cycles a set number of cycles.  Also, Maha's "top-off charge of 100mA", which sounds like a great idea for almost-charged batteries, and the reason I thought it would do better than the LaCrosse, does not seem to turn on.  I've monitored my batteries for about an hour before they finished charging, in 5-minute intervals: and I have not seen the charge switch to 100mA even once.  You would think it's time to top off if the charge hasn't went up for an hour...  Maybe for really-fast charging modes this turns on at some point.  On the other hand, Maha lets the batteries rest an hour between discharge and charge, which tends to be better on the batteries.  In particular, without the 1-hour break the low-capacity batteries tend to lose about 4% charge each cycle; this does not happen with the Maha.  After finishing cycling, on the LaCrosse you see only the last capacity; on the Maha you can see all of them.  It is a little unfortunate that the Maha displays this only at the end-- it would be nice to know the capacity is going down so I should stop cycling, before finishing all the cycles.
Comment: What I am doing is, asking for *any* good charger. This information is NOT "rarely useful to others", and will NOT become obsolete quickly, since new chargers tend to come out no more often than once per several years per company. In particular, I searched a long time for this information (upwards of 16 hours), and had to resort to asking this question on stackexchange.
Comment: The way I understand this guideline is, "recommendations for specific products" means I give a product and ask for recommendations of it, kinda like asking for reviews.  Asking this type of information would become obsolete quickly because there exist many good products, places to buy them would change, and stackexchange does not wish to keep a review for every product out there.
Answer: I've had good luck with Maha chargers. The key things you want are pulse charging and a separate charge circuit for each battery. Cheaper chargers only measure the charge on 1 of 4 or 1 of 2 batteries, and unless they are all have exactly the same capacity and charge level, you either under or over-charge some of the cells in a group.
Most of Maha's chargers do both of those things, but read the descriptions. If you're in the US, you can order Maha chargers from Thomas Distributing.
As I recall, their website includes a detailed description of each model that they sell.
Comment: Thank you for this information.  As far as I am aware, all the chargers I tried have pulse charging, and have separate circuitry for each battery (in fact display the voltage of each battery).
Comment: As I mentioned, Maha was the charger that I was getting ready to try next.  The thing that stopped me was, some people posted that their "delta T monitoring for ending charging" (only present in MX-9000) failed to work because the sensor was too narrow to get the battery temperature accurately.  Do you know for sure that the MX-9000 stops charging once the battery, say, overheats?  Without displaying the battery temperature, there's no way for me to know for sure that it checks it.  Maybe the charger the person claimed was leaking his (cheap) batteries was just defective?
Comment: @Alex, For a healthy battery, measuring the battery voltage between charging pulses is a perfectly adequate way to avoid over-charging. My older Maha charger does not have a temperature sensor, and I've never melted a battery in it. I tend to by either Maha or Eneloop batteries though, not cheap off-brand cells. My guess is that the posters reporting melted batteries had defective cells, and that for some reason the battery did not make good thermal contact with the charger.

What is a good NiMH charger?


PHP MySQLi Lock Tables Query Sometimes Does Not Complete

Question: I am attempting to lock some tables while running some code and unlocking the tables when I am done.
Process:

Run Lock Tables MySQL Query.
Run some PHP Code.
Run Unlock Tables MySQL Query.

While running this process, 9 times out of 10 everything runs perfectly. Sometimes, when I run my query no response comes back from MySQL and PHP just waits for a response. Since no response happens, I never get to steps 2 or 3 and the table stays locked indefinitely. I am running the exact same Lock Tables Query in every single attempt.
After some research, I found that the problem happens when a Second Server writes to the database and then the First Server tries to do a "LOCK TABLES" query. It appears that the Second Server's write does a "metadata lock". I believe this is due to MySQL having the "autocommit" feature enabled and the transaction is not yet completed. So when I attempt to lock the tables, MySQL never responds and the "show processlist;" has "Waiting for table metadata lock | LOCK TABLES ..." listed in it until I manually kill the process.
I am locking Numerous tables. Below is a similar example to my actual table query. I am using the same table multiple times with different aliases based on the queries I am attempting to prevent from accessing the tables.
$sql = "LOCK TABLES table1 as t1 WRITE
                    , table2 as t2 WRITE
                    , table3 WRITE
                    , table2 WRITE
                    , table4 WRITE
                    , table1 WRITE
                    , table5 WRITE
                    , table5 as t5 WRITE
                    , table6 as t6 WRITE
                    , table7 as t7 WRITE
                    , table7 WRITE
                    , table8 as t8 WRITE
                    , table9 t9 WRITE
                    , table10 t10 WRITE
                    , table11 t11 WRITE
                    , table12 WRITE;";

$this->mysqli = new mysqli(
    $this->credentials->server
    , $this->credentials->user
    , $this->credentials->password
    , $this->credentials->database
);

try{
    error_log('before first attempt lock tables '.$sql);
    $this->mysqli->query($sql);
    error_log('after first attempt lock tables');
} catch (Exception $e){
    error_log('Error locking tables: '.$e->getMessage());
}

error_log('After try catch.');
if($this->mysqli->error){
    error_log('lock table error: '.$this->mysqli->error);
}

When the process fails, I see "before first attempt lock tables" in my PHP  Error log. I do not see any of the other error_log() calls. After some checking, I determined it is because PHP has not received a response from MySQL.
I never get into the Catch Exception, since MySQL is not returning an error. MySQL is not returning anything unless I manually kill the MySQL Lock Tables Process.
If I don't kill the process, the PHP code never stops waiting for a response from mysql.
I am confused why the "LOCK TABLES" query is not gracefully waiting for the "metadata lock" to complete and then running. It was my understanding that more than one server was allowed to write to a database and the lock table features would work together instead of one hanging indefinitely.
Answer: Gag!  LOCK TABLES is essentially unnecessary if you are using ENGINE=InnoDB.  If you are still using MyISAM, convert!
After converting, you will need to understand how to put things in "transactions" (BEGIN...COMMIT) and use SELECT ... FOR UPDATE.


Where in the PHB is the information on the different regions dwarves come from?

Question: I thought I saw somewhere in the 4e Player's Handbook the different regions the dwarves live in, but now I can't find it. (I would like to use a dice to randomly select my region to help build my backstory/personality.) What page is it on? If I'm remembering wrong and it's not in the PHB, where is it?
Comment: I'm voting to close as unclear until you've specified which 4e setting your group is using: default (the one in the PHB/DMG/anything which doesn't specify otherwise, unofficially called 'Points of Light'), Dark Sun, Eberron, Forgotten Realms...?
Answer: As @ObliviousSage stated in comments, there is very little actual geography in the 4e PHB, since the "Points of Light" setting that is the default for 4e has very little content, and is largely just intended to simply set a general tone so GMs can put whatever they want in it.However, 4e also has campaign setting books for Dark Sun, Forgotten Realms, and Eberron. Those books would definitely have information on dwarven culture and where dwarves are found in that setting.


Where to define grid for bilinear levelling in Marlin

Question: I'm using firmware Marlin 2.0.3 on an Anet A8 printer. I'm using a Roko SN04-N NPN bed leveller. I've managed to set up 3 points bed levelling but I wanted to try the bilinear levelling.
Issue is, the sensor goes out of the aluminum bed ever so slightly during levelling, resulting in the printing head crashing on the bed.
Where can I set the grid for the bilinear levelling in the config file? I didn't find the option in the file and Google wasn't of any help this time.
Comment: Did you define "[Z-probe boundary limits](/q//8153/)"? Please post your changes to the configuration.h and configuratio_adv.h as in the latter file the boundaries are set in Marlin 2.x; e.g. #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE. Without posting the values, it would be guessing what is wrong. If you used the Anet A8 configuration files from [Anet A8 config.](https://github.com/MarlinFirmware/Configurations/tree/master/config/examples/Anet/A8) you will find that these are incomplete with respect to bed limits, these files require updating!
Comment: @0scar yes I did and it's ignoring it! [This is my configuration.g](https://pastebin.com/i4jtrk2W) and this [is my configuration_adv.h](https://pastebin.com/Vf42M9Ed). I think I got the config for the Anet from the Marlin examples, but I'm not 100%sure. Where should I find a complete setting?
Comment: No it is not ignoring it, your bed limits are incorrect, I've updated the answer to your specific problem. Basically your left limit is incorrect (too far left), hence the sensor is not on the plate. Hope you can fix it now, happy printing! :-)
Answer: If you have managed to setup 3-point levelling, you should be able to enable bi-linear levelling in the firmware.
From the configuration.h file for Marlin firmware you can find the following options:

/**
 * Choose one of the options below to enable G29 Bed Leveling. The parameters
 * and behavior of G29 will change depending on your selection.
 *
 *  If using a Probe for Z Homing, enable Z_SAFE_HOMING also!
 *
 * - AUTO_BED_LEVELING_3POINT
 *   Probe 3 arbitrary points on the bed (that aren't collinear)
 *   You specify the XY coordinates of all 3 points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_LINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_BILINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a mesh, best for large or uneven beds.
 *
 * - AUTO_BED_LEVELING_UBL (Unified Bed Leveling)
 *   A comprehensive bed leveling system combining the features and benefits
 *   of other systems. UBL also includes integrated Mesh Generation, Mesh
 *   Validation and Mesh Editing systems.
 *
 * - MESH_BED_LEVELING
 *   Probe a grid manually
 *   The result is a mesh, suitable for large or uneven beds. (See BILINEAR.)
 *   For machines without a probe, Mesh Bed Leveling provides a method to perform
 *   leveling in steps so you can manually adjust the Z height at each grid-point.
 *   With an LCD controller the process is guided step-by-step.
 */
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
//#define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING

If you are using 3-point levelling you enabled constant AUTO_BED_LEVELING_3POINT by removing the comment characters (//):
#define AUTO_BED_LEVELING_3POINT

to enable bi-linear levelling, you should remove the comment characters before constant #define AUTO_BED_LEVELING_BILINEAR:
#define AUTO_BED_LEVELING_BILINEAR

Definition of the grid is done by specifying how many point you want to have using constants GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y:

#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

  // Set the number of grid points per dimension.
  #define GRID_MAX_POINTS_X 3
  #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X

The code above shows the default definition of a 9 point (3 x 3) grid.
Note that this will only work well if the area for the sensor to reach safely is correctly defined. If the sensor is missing the build plate, you have not correctly defined the limits for the sensor. Question "How to set Z-probe boundary limits in firmware when using automatic bed leveling?" has an accepted answer that describes how to define an area on the plate that the sensor may reach (the answer on this question also discusses Marlin 2.x).

In the specific case of the OP (after posting the config files)

From the posted configuration files your probe position can be obtained:
#define NOZZLE_TO_PROBE_OFFSET { 25, 55, 0 }

So your probe is at the right-back when facing the printer. Also your bed area attempt (commented) and the current active bed area can be obtained:

#if PROBE_SELECTED && !IS_KINEMATIC
  //#define MIN_PROBE_EDGE_LEFT 5
  //#define MIN_PROBE_EDGE_RIGHT 200
  //#define MIN_PROBE_EDGE_FRONT 55
  //#define MIN_PROBE_EDGE_BACK 200
  #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif

From these excerpts it is clear that the bed limits are incorrectly defined.
Following the theory from this answer the probe is only allowed to visit the following (dark red) area:

This area is defined as:

  #define MIN_PROBE_EDGE_LEFT (PROBE_OFFSET_X_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (PROBE_OFFSET_Y_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)

which translates to:

  #define MIN_PROBE_EDGE_LEFT (25 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (55 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)

As seen in the commented //#define MIN_PROBE_EDGE_LEFT 5 and uncommented #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE (equals 10) left probe limits, you are at least respectively 20  or 15 mm short, hence the sensor is not on the plate on the left.
Comment: I did try that, but the printer is still ignoring probe offset and probing boundaries. I've tried also [this bugfix](https://github.com/MarlinFirmware/Marlin/pull/16367) but still probing outside of the bed
Comment: @vale.maio2 I've updated the answer, from your config files it was clear that the incorrect value for the left boundary was used causing the sensor to be off-plate on the left.
Comment: thank you very much for your correction, but now when selecting the auto levelling, it just probes the center of the bed and stops there, same when printing something. Unfortunately I have to switch back to 3 points.
Comment: @vale.maio2 That means that `Z_SAFE_HOMING` is active, strange that it stops... Look for more information on enabling bi-linear leveling [here](https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling). Did you also determine the correct Z-offset and set it with `M851`?
Comment: yes it's active but it's not an issue with 3 point levelling. I'll have a read at that documentation, but I've also discovered that the bed is absolutely uneven. I need to make it even fist, then even 3 point levelling should suffice. Thank you again for your input.
Comment: @vale.maio2 Note that the 3-point X coordinates for the 2 left points are also incorrect, but because of the width of the sensor, you manage to get probings at X = 20, factually this should be `25 + MIN_PROBE_EDGE`! Note that the answer does answer where you need to adjust the grid points, too bad you run into another issue.
Answer: Currently on 2.1.1 it is just
#define PROBING_MARGIN

On line 1500 of Configuration.h
For example,
#define PROBING_MARGIN 10

Comment: Hi and welcome to SE.3DP. Thanks for the update. I have added code formatting for you and a link to the actual line in the code, just to bulk your answer out a bit - to make it more substantial. Please don't forget to take the [tour].
Answer: Note for anyone looking at the answer above, but in 2.1.x:
The #define lines have been renamed:
#if PROBE_SELECTED && !IS_KINEMATIC
  #define PROBING_MARGIN_LEFT PROBING_MARGIN
  #define PROBING_MARGIN_RIGHT PROBING_MARGIN
  #define PROBING_MARGIN_FRONT PROBING_MARGIN
  #define PROBING_MARGIN_BACK PROBING_MARGIN
#endif


Which projective varieties cannot appear as an exceptional divisor of a blow-up of the projective space

Question: I am looking for examples of projective varieties (over $\mathbb{C}$) of dimension, say $n$ which cannot appear as an exceptional divisor of a blow-up of $\mathbb{P}^{n+1}$ along some closed subscheme. Any idea/reference will be most welcome.
Comment: Is not the exceptional divisor always covered by rational curves (because it is the Proj of the normal sheaf)? This should exclude all the non-uniruled varieties, I think.
Comment: @FrancescoPolizzi By your argument that it is the Proj of a normal sheaf, can't we further say that the irreducible components of the exceptional divisor must be rational?
Comment: unirational, but not rational in general. If you blow-up a smooth curve $C$ of genus $g\geq 1$ in $\mathbb{P}^3$, the exceptional divisor is a $\mathbb{P}^1$-bundle over $C$, that is not rational because it has irregularity $g$.
Comment: @FrancescoPolizzi Thanks. You could write your comments as the answer. This does answer my question to a large extent.
Comment: Ok, I wrote a short answer
Comment: btw, in my last comment "unirational" should be "uniruled".
Answer: The exceptional divisor is the $\operatorname{Proj}$ of the normal sheaf, hence it is covered by rational curves. This excludes all the non-uniruled varieties.


How do you get to wave 15 of the pumpkin moon in terraria?

Question: I made an arena, and it can kill everything but I can't make it all the way to round 15. I'm doing it with melee: dragon armor and a mushroom spear.
Comment: Are you using the lava in any way? I would assume any enemy not killed by you directly and instead killed by lava would not count towards the wave score, which would make reaching the 15th wave take more time. Also, are you starting the event at near dawn (as from the screenshot)? Because the event ends at dawn (4.30 AM on the game)...
Answer: Maybe this is a silly answer but I found that it was trivial to get to Wave 15 with one other player fighting with me in a simple arena made of a dirt pit with a couple levels of platforms. We both had level-appropriate equipment (we only used our characters while playing on our specific world together) and could effectively kill anything within seconds of it spawning, going through multiple waves every minute.
Everything's easier with a friend!
Answer: Try making a 10 block high, 5 blocks across with lava in the middle farm.
And put water candles (you can find them in the dungeon) inside.
And try having a minion with you to kill them faster. That's what worked for me. And also make sure your on hardmode.
Answer: In the mobile version of Terraria, it won't show you the percentage of the event. The only way to get to wave 15 is to kill a lot of monsters. Kill everything you find insight. Getting a friend or two to help is a good idea too as it makes it way quicker and easier. Also, pinch your screen so that your avatar is really close as it increases the spawn rates off screen, or at least that's what I thought. Your using Dragon Armor and a Melee weapon, so you shouldn't worry too much about not seeing monsters. Use spawn rate increasing items like the Battle Potion and Water Candle. Hope this helps.


What causes market-wide trends?

Question: What cause market-wide trends in general, rather than company-wide trends?
Answer: The psychology of the market participants does in both situations.
A general market trend can cause participants in individual companies to follow the general market trend, even if the company's health is opposite to the general market trend. A general market trend can be sparked by some economic event but is driven by the fear/greed of market participants.
Similarly, the trend of an individual company may be sparked by some financial news about the company or the general market consensus but is driven by the fear/greed of the company participants.
Comment: Is the same applied to mid-term or long-term trends?
Comment: Short-term, mid-term and long-term trends are all driven by the psychology of market participants. Fear breeds more fear and greed breeds more greed.
Answer: Algorithmic trading has been floated as something that creates correlative movement, as well as deepening particular moves.
From: https://www.wsj.com/articles/behind-the-market-swoon-the-herdlike-behavior-of-computerized-trading-11545785641
"...behind the broad, swift market slide of 2018 is an underlying new reality: Roughly 85% of all trading is on autopilot—controlled by machines, models, or passive investing formulas, creating an unprecedented trading herd that moves in unison and is blazingly fast."
Answer: Many factors contribute to and influence market direction.  This can  include change in interest rates, change in the price of oil, inflation, monetary policy (Quantitative Easing), geopolitical events (invasion of Kuwait),  economic events (low unemployment numbers, consistent number of jobs created, consumer confidence and spending), legislation (Trump tax cuts) geopolitics (Brexit, invasion of Kuwait), political chaos (Washington today?), etc.
Some of the above events also affect individual companies particularly if it's a sector  affected by them. Interest rates and banks?  Oil price and manufacturing?  Consumer spending and retail stores?  Company trend basically comes down to earnings.  Anything that affects earnings is going to point the direction.  M&A?  New contracts?  New product lines?  Successful clinical trials?  Lawsuits?  Slowing corporate earnings and lowered forward guidance?
Market psychology can come into play in both areas.  Fear and uncertainty can take hold despite little change in the economy (see markets down 20% over the past two months).
Answer: Anything that affects the economy as a whole will affect the markets as a whole.
Additionally, anything that causes uncertainty tends to be bad for the markets. I read once -- haven't verified it but sounds plausible to me -- that the market tends to go down in the months leading up to an election, and then whoever wins, it goes up after the election. At first it may sound irrational to say that not knowing what government policy will be hurts more than knowing that government policy will be bad for business, but it's not as crazy as it sounds. Government policy isn't usually good for all businesses or bad for all businesses. It's good for some and bad for others. When investors don't know what the policy will be, they don't know what businesses to invest in, so they hold back, wait and see. Once you know, then you can safely (more or less) invest in the businesses that will benefit from the new policy.
As I write this, December 2018, the US stock market is taking a beating. Most analysts blame this on, (a) Federal Reserve raising interest rates, (b) unresolved trade issues with China, (c) government shutdown over border wall controversy. Note that (b) and (c) are mostly in the "uncertainty" category.

What causes market-wide trends?


Water pressure tank

Question: When I turn on my faucet the psi on my tank show 60 psi and when it drops to 40 it turns on but only gets to 55psi then it drops to 30psi before turning on then it only fills to 50psi and drops down to 20 and so on  till it is about 10psi.when I turn my faucet off the gradually returns to 60 psi with a couple of cycles why is this doing it?this has just started happening this week. It put this in last winter and never had a problem so what do you think?
Comment: Hello, and welcome to Home Improvement. Without more info, I'd guess that you're drawing more water than the pump can supply continuously; add some more info (where is this being pumped from? add a diagram?) and we'll be able to say more. And, you should probably [take our tour](//diy.stackexchange.com/tour) so you'll know the details of contributing here.
Comment: I agree with Daniel it really looks like a well that can not supply the amount of water being used.+
Comment: @EdBeal Agree completely. Low producing wells, when properly configured, will have sensors and controllers that cycle the pump to avoid "sucking air" when the water level in the well drops too low.  A solution, albeit an expensive one, is a non-pressurized holding tank between the pressure pump and the well pump. This will need to be engineered, not a DIY project unless you do a TON of research.
Comment: Thanks for the help it has been working for a year when I put in a new tank in and it's been working fine till yesterday and I put in a picture.
Comment: It's possible a restriction is causing an issue + but since it takes several cycles possibly the. Heck valve is stuck if you have one up by the tank.
Answer: This sounds like there must be a major restriction between the actual pressure switch and the pressure gauge.
The key symptom is that the cut-in /cut out pressure is changing - and that's not how (what appears to be a perfectly standard Square-D pumptrol, though the picture is a bit low-resolution to be certain) pressure switches work.
With a low well output, if you had the version of the Pumptol that protects the pump from low water, it would simply shut off until it was manually reset at about 18 PSI. I have one of those, and I'm pretty sure it does not go as low as 10 PSI without shutting itself off, though its documentation is vague. It may be some fixed offset below the cut-in pressure.
Barring some fault condition I'm not familiar with, the pressure sensor of the pump switch is simply going to switch on at 40PSI (always) and off at 60 PSI (always) but that is the pressure at the switch's sensor. If there's some sort of restriction causing the pressure at the switch and the pressure at the gauge to be different with the water flowing, then behavior like you have reported becomes plausible.
Comment: So you think it might be build up off calcium in the pressure switch pipe?
Comment: I have no particular theory as to what the restriction might be.

Water pressure tank


Did the star lead the Magi to King Herod in Jerusalem before leading them to Bethlehem?

Question:
Matthew 2:1 After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi a from the east came to Jerusalem 2and asked, "Where is the one who has been born king of the Jews? We saw his star when it rose and have come to worship him."
3When King Herod heard this he was disturbed, and all Jerusalem with him. ...
9After they had heard the king, they went on their way, and the star they had seen when it rose went ahead of them until it stopped over the place where the child was. 10When they saw the star, they were overjoyed.
Answer: The scripture states that the Magi did NOT go to Herod the Great upon being led to Jerusalem by the star. They enquired in the city about the anticipated arrival of the King of the Jews. After making their enquiries, Herod was told of their presence in the city, and he enquired after them. In other words, he required their presence, to explain themselves. They dare not refuse this audience with king Herod. To decline would cause immediate suspicion that they were spies from a foreign land far away, and so the Magi pitched up at court - pronto. Yet that simple statement you quoted from Matthew 2:1-2 - they came to Jerusalem (not to Herod, at the first) - means that the star led them to Jerusalem - to a city, not a person.
They had set out on their huge journey already believing that the rare movement of stars in the night sky in the spring heralded the coming birth of a new king of the Jews. That is because the Magi held particular beliefs about particular movements of the constellations at particular times. Zoroastrian Magi viewed Jupiter as representing a new king; Saturn the old. The planets coming together would signify a change of ruler. This happening in Pisces would speak to them of Israel, as they associated Pisces with Israel. Once arrived in Jerusalem, their open declaration to Herod as to why they had come garnered them further direction – the religious leaders, who had also been summonsed by Herod, confirmed that prophecies showed Messiah would be born in Bethlehem. Herod sent them to Bethlehem (Matthew 2:7).
An article on this was in 1 September 2009 'Weekend' magazine which was reviewing a BBC2 documentary on Christmas Eve that year. It gave that explanation of David Hughes, Professor of Astronomy at Sheffield University.
Then, the star appearing to stand still above a house in Bethlehem would absolutely assure them that their astronomical calculations and astrological expectations about a new king of Israel were sound. That is why the Bible records that "they were overjoyed" now being able to personally deliver their gifts for a king to this new child-King of the Jews. But the answer to your question is, "No, the star did not lead them to King Herod - it led them first to the city of Jerusalem, after which it led them to a particular location in Bethlehem."
Comment: Peace be upon you wrote "As they associated Pisces with Israel". How so?
Comment: That statement was in the article of David Hughes, Prof. of Astronomy at Sheffield Uni, England, 1 Sept. 2009 'Weekend' mag.  I have the original copy at home, but finding it will require some time. However, from memory, I think it was just a statement he made and, given his expertise, I assume he had good reason for making it. @יהודה
Comment: Thanks for the response. What was his reasoning and basis for making such a claim? Is there a nation, people, or person associated with Aries? Leo?
Comment: @יהודה    As I said, I'd have to find the article amongst reams of newspaper and magazine article clippings, but I'm confident he did not expand on the bare statement that the Magi associated Pisces with Israel. You might find his article on an internet search, or his biography.
Answer: The same question was asked on Quora. Below is my answer there.
Let's read the Gospel carefully and analyze it using common sense:
After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem 2 and asked, "Where is the one who has been born king of the Jews? We saw his star when it rose and have come to worship him."…
7 Then Herod called the Magi secretly and found out from them the exact time the star had appeared. 8 He sent them to Bethlehem and said, "Go and search carefully for the child. As soon as you find him, report to me, so that I too may go and worship him."
9 After they had heard the king, they went on their way, and the star they had seen when it rose went ahead of them until it stopped over the place where the child was. 10 When they saw the star, they were overjoyed. 11 On coming to the house, they saw the child with his mother Mary, and they bowed down and worshiped him. Bible Gateway passage: Matthew 2 - New International Version.
The Gospel says about only two separate sightings of an unusual celestial object that the Magi identified as a new star. Now, where were the Magi when they had those sightings? The Gospel does not say it. We must guess.
The first time the Magi saw his star when it rose and after that, they have come to worship him. Only one sighting means the Magi were in the vicinity of Jerusalem. According to the beliefs of their time, they concluded the rising of a new star over the capital means that a future great king of the Jews was just born there. The Magi hurried there to announce that fresh big news, to worship a newborn in the royal palace, and to get a valuable reward from the rich king for their good prediction and their job. You ask: Did the star lead the Magi to King Herod? Strictly speaking, no. The king could ignore them. But by curiosity "Herod called the Magi secretly and found out from them the exact time the star had appeared."
From Jerusalem to Bethlehem the Magi followed the road winding through the hills, not the star. According to the Gospel, the second time the Magi saw the same star after "it stopped over the place where the child was. 10 When they saw the star, they were overjoyed."
Hence according to the Gospel, the star never led the Magi. See https://www.quora.com/How-did-the-bogus-Star-of-Bethlehem-story-ever-get-started-It-is-so-full-of-inaccuracies-and-improbabilities-its-ridiculous/answer/Alexander-Reznikov-3 for more details.
Answer: From the account in Matthew chapter 2 the wise men from the East came first to Jerusalem.  They knew about the prophecy of the birth of "the one who is born king of the Jews".  But they did not know exactly where to locate the child.  Herod interrogated the Jewish "priests and the experts in the law" who confirmed that the Christ would be born in Bethlehem.

Matthew 2:1-6: After Jesus was born in Bethlehem in Judea, in the time of King Herod, wise men from the East came to Jerusalem saying, "Where is the one who is born king of the Jews?  For we saw his star when it rose and have come to worship him."  When King Herod heard this he was alarmed, and all Jerusalem with him.  After assembling all the chief priests and experts in the law, he asked them where the Christ was to be born.  "In Bethlehem of Judea," they said, "for it is written this way by the prophet:  'And you, Bethlehem, in the land of Judah, are in no way least among the rulers of Judah, for out of you will come a ruler who will shepherd my people Israel.'"

Herod then told the wise men to go to Bethlehem.  But it was the supernatural movement of this heavenly star that drew them to the exact location where the child was.

Matthew 2:7-12: Then Herod privately summoned the wise men and determined from them when the star had appeared.  He sent them to Bethlehem and said, "Go and look carefully for the child. When you find him, inform me so that I can go and worship him as well."  After listening to the king they left, and once again the star they saw when it rose led them until it stopped above the place where the child was.  When they saw the star they shouted joyfully.  As they came into the house and saw the child with Mary his mother, they bowed down and worshiped him. They opened their treasure boxes and gave him gifts of gold, frankincense, and myrrh.  After being warned in a dream not to return to Herod, they went back by another route to their own country.

The star led them to the general direction of Jerusalem, and then it moved position till it came to the specific location in Bethlehem (about 5 miles south-east of Jerusalem, I think) where it stopped. The star did not lead them to Herod.
Paragraph 8 in this recent article (written by a Christian) may be relevant to your question.  The article was prompted by the "great conjunction" of Jupiter and Saturn that's happening righ now.  The last such conjunction took place in 1623 and the next one will be in 2080: https://wagingwisdom.com/2020/12/16/a-rare-astronomical-event-is-happening-this-christmas-is-it-the-star-of-bethlehem/
Comment: Lesley: If that so-called "star" had been from God, why did it direct them to King Herod Jesus' enemy in Jerusalem and not guide them to Bethlehem? Why did it forsake the magi after it had taken them to Jesus, thus leaving them free to return to Herod? Why did not the "star" guide them back another way, if it was from God, and not make it necessary for God to intervene by sending an angel to them to direct them not to report back to Herod?
Comment: @OzzieOzzie  Noting your comment, I would just suggest that the triple conjunction involved had 3 phases, one in spring, another early autumn (which the Magi could calculate in advance and so set out in the right direction) but the third was the key one. It did not happen till after their audience with Herod. They were led in stages as all such rare conjunctions of planets happen in stages. Jerusalem was a necessary stage to prepare God's people there for the imminent arrival of their Messiah.
Comment: Read the opening sentence in the answer given by Anne: "The scripture states that the Magi did NOT go to Herod the Great upon being led to Jerusalem by the star."The star led them to Jerusalem, not to Herod.
Comment: Lesley: Correct, I do not disagree with that, however, my thoughts are why to Jerusalem first and not guide them to Bethlehem where the young child was living.
Comment: I think you may have an opinion on this, based on this answer you gave: https://hermeneutics.stackexchange.com/questions/53854/did-the-star-lead-the-magi-to-king-herod-in-jerusalem-before-leading-them-to-bet/53857#53857
Answer: Yes,  The magi were directed to Jerusalem and not Bethlehem.  Then it was King Herod that directed them to Bethlehem.  The next question is why would the star/God do that since obviously, God knew where Jesus was born?  What that star did was set off a wicked King that once he found out about the prophecy proceeded to execute all children in the land below the age of 2 (Matthew 2:16).  Would an all-loving God put those children in danger like that?
Comment: Welcome to BHSX.  Thanks for your contribution.  Please take the tour (link below) to better understand how this site works.
Comment: This answer appear to ask a series of further questions without drawing to a conclusion.  Please add some references and conclusions.


Limiting node.js's memory usage

Question: I am trying to limit a node.js application from using to much memory and I've found out about the --max-stack-size & --max_executable_size options that are available within V8 to pass when invoking the file, but how should I combine these and possible other arguments to limit max memory usage to 1GB?
Answer: https://github.com/joyent/node/wiki/FAQ

What is the memory limit on a node process?
Currently, by default v8 has a memory limit of 512mb on 32-bit
  systems, and 1gb on 64-bit systems. The limit can be raised by setting
  --max_old_space_size to a maximum of ~1gb (32-bit) and ~1.7gb (64-bit), but it is recommended that you split your single process
  into several workers if you are hitting memory limits.

Value is in megabytes, I believe.
Comment: The default limit increased to ~1.5GB around node 2.  See https://github.com/nodejs/node/issues/3370#issuecomment-148108323
Answer: It's now, --max-old-space-size no technology limits...
for example node --max-old-space-size=8192 ./app. We create limit in 8Gb
Answer: There are two ways to increase the maximum memory size of V8:

Using a CLI option: node --max-old-space-size=4096 memory.js
Using an env variable: NODE_OPTIONS='--max-old-space-size=4096' node memory.js

Here's a small script that shows you the memory usage of your application:
const process = require('node:process');

const used = process.memoryUsage().heapUsed / 1024 / 1024;
console.log(`This app is currently using ${Math.floor(used)} MB of memory.`);

Limiting node.js's memory usage


How to determine the side on which a point lies?

Question: Suppose we have a linear equation and a point in the plane, then how can one determine on which side of the line the point lies?
Answer: Let your line be given by $ax+by=d$, and call $\vec n=(a,b)$ the normal vector of the line. Let's label the side $\vec n$ points to $+$ and the opposite side $-$. Then for any point $(x,y)$ in the plane, the sign of
$$ax+by-d$$
determines which side the point $(x,y)$ is on. Notice that this is $0$ if and only if $(x,y)$ is on the line, so all points not on the line get $+$ or $-$.
Here's a picture illustrating the situation:
Comment: I'm a little confused, are `x` and `y` reused here?  Shouldn't it be "Then for any point (x1, y1)" ?
Comment: When specifying the line as $L = \{ (x,y) \in \mathbb R^2 : ax+by=d \}$, the variables $x$ and $y$ are not bound outside of the definition of $L$. If you prefer to call the point in consideration $(x_1, y_1)$ you are free to do so, but $(x, y)$ is fine as well.
Answer: Are you meaning that you have a point $(x_0,y_0)$ and a line $y=a+b x$ ? If this is the case, compute $y_*=a+b x_0$ and compare $y_*$ to $y_0$. If $y_0 \gt y_*$, then the point is above the line; if $y_0 \lt y_*$, then the point is below the line; If $y_0 = y_*$, then the point is along the line.
Answer: Suppose the line is
$$ax+by+c=0\iff y=-\frac abx-\frac cb\;,\;\;b\neq 0\;\;(b=0\;\;\text{is a vertical line and a trivial case})$$
This means a point on the plane is on this straight line iff it is of the form $\;\left(x\,,\,-\frac abx-\frac cb\right)\;$ .
Well, now take a general point $\;P=(\alpha\,,\,\beta)\;$ on the plane , and then
$$\begin{align*}\beta<-\frac ac\alpha-\frac cb&\implies P\;\;\text{is on the left half plane of the line}\\
\beta>-\frac ac\alpha-\frac cb&\implies P\;\;\text{is on the right half plane of the line}\\
\beta=-\frac ac\alpha-\frac cb&\implies P\;\;\text{is on the line}\end{align*}$$
Comment: This doesn't make much sense, you're not picking any "side" of your hyperplane this way.
Comment: Am I not, @OlivierBégassat? Then what does "on the left...on the right" mean? When one draws a line on a given plane with the usual convention of axis, there is always "a left" and "a right" of that line (unless it is a horizontal line $\;y=k=$a constant, a particular case easily dealt with).
Comment: My bad, I got confused and for a moment ^^
Answer: Here's a strategy that's independent of how the equation is written.

Substitute your point ($P$) into the line equation. If equality still holds, then (of course) $P$ lies on the line, and you're done. Otherwise,
Substitute the origin, $O(0,0)$, into the equation. If $P$ and $O$ violate the equality in the same way (eg, both points making the left-hand side of the equation larger than the right-hand side, or both making the right-hand side larger than the left-hand side), then $P$ and $O$ are on the same side of the line; otherwise, the points are on opposite sides of the line.

Note that this strategy works for curves other than lines.


2006 Ford XLT Front Dash Vent Door plastic lever broken that was attached to the Mode Actuator (which works)

Question: 2006 Ford Explorer XLT.  Got a loud snap sound with small piece bouncing around under dash on passenger side. Air flow changed to def and floor only. Searched online, pulled glove box, Front vent actuator door plastic lever broke pulled many dash parts, all the center dash area with radio and HVAC controls, the whole center console, lower panels on passenger side, but can't get to it! I can barley get a finger on it as it's to the right of the center dash area and up and to the left of the glove compartment area behind metal bracing. Please tell me how to get to this thing without pulling the whole dash or paying $1200.00 to the dealer for a 20-30$ self fix.... Help! If I can just get to it, I'm gonna use the (drill hole in plastic lever above the break, use wire tie between this hole and hole in the "working" actuator metal plunger shaft) method. Thanks so much!
Comment: There is more than one mode door actuator, need to know which one, driver, passenger mode door actuator? Is it on the front or rear of the AC heater box?
Comment: Welcome to Motor Vehicle Maintenance & Repair!
Answer: If its the one I think it is.

.

.
Answer: It's the center console "face" vents door with the plastic control arm on its right side which connects to its own vaccum actuators metal shaft. Actuator works but the plastic arm of the vent door snapped off. When glove compartment is removed this actuator up behind the top left corner of the glove compartment opening and is behind a metal support/bracket. I've removed everything from the center console but can't get to it from that side either. Does that help? I've googled tons of sites but none are clear on how you get to this area to work on it. Seems that all show pictures of what it looks like and after the fix pictures, but none show actual removal or fixing in place. Thanks.


How to tell if a high-res flac file has been upsampled from a CD-quality file?

Question: Because I might encode my music in lossy format for other devices or edit them, I prefer to keep a high-res copy of my music. However, I know that it is possible to upsample a file using ffmpeg and it would appear the same as an authentic high-res file with ffprobe. Is there anyway I can tell apart a "fake" high-res file (converted from CD-quality or mp3/aac) apart from a "real" high-res file (exported high-res by the producer)?
Comment: Did you tried [Audiochecker](https://windows-cdn.softpedia.com/screenshots/Audiochecker_1.png)?
Comment: Or AuCDtect? Website http://tausoft.org/ seems to be down right now, but the tool can be also found on other sites
Comment: @user124853 Yes, I've tried that. Unfortunately I'm running macOS so it's really inconvenient to use it. Plus I think it's based on aucdtect.
Comment: @Reeno I've been using aucdtect. Only problem: it does not support high-res files. It is stated clearly on the website that it can only work with CD-quality files and when I use it with high-res files to confirm it crashes.
Comment: @Reeno There is also a bit of controversy around effectiveness of aucdtect on hydrogenaud.io forum where it is released. Some say that after strong dithering or adding lots of noise a low-quality mp3/aac is indistinguishable from lossless sources for aucdtect.
Answer: Let's get some basics out of the way first.
An audio format is basically defined by three different things: sample rate, bit depth and compression type. The compression type can be either lossless (WAV, PCM, FLAC, ALAC) or "lossy" (AAC, MP3, OGG, MQA, etc). Lossy compression works by shaping the quantization noise so it's masked by the remaining content and inaudible. Lossy formats are characterized by their bit-rate: the higher the bit-rate, the less quantization is done.
The typical life cycle is the following: recording, mixing and happens at 96kHz floating point. When that's done, there are typically two masters made: a studio master at 96kHz/24-bit and a CD master at 44.1kHz/16-bit.
The label will send one of these two to the distribution channel, e.g. Spotify. Which one depends on the contract. Spotify will then create the formats that they need for their streaming platform, which almost always includes lossy compression. For example Spotify uses OGG at 320 kb/s. Apple Music uses AAC at 256 kb/s. Which format gets to the customer depends on the contract between the customer and the distribution.

Is there anyway I can tell apart a "fake" high-res file (converted from CD-quality or mp3/aac) apart from a "real" high-res file

Here are a few things to look for in a spectral analysis

Each format has it's own rolloff: CD drops like a rock at 20 kHz and MP3 drops steeply at 16 kHz. If you have a 96 kHz file with these sharp drop offs, it's likely been up-sampled.
Inspect the content above 20 kHz. If there is random "noise like" features in there, it's probably genuine. If it has very little content and/or the content looks like a low-pass filtered mirror image of the content below 20 kHz, it's been up-sampled.
You can look at correlation at high frequencies. For a genuine recording this will mostly be uncorrelated. If there is significant correlation, it's a potential sign of "joint stereo coding" which could hint at lossy compression.
Look at the recording date: If it's been made before 1990 it's almost guaranteed to be up-sampled. There never was a digital studio master and the best they can do is to sample a tape master.

Some formats like MQA, include authentication, i.e. they put a "seal" on the content and can detect whether the "seal" has been tampered with. It's also possible to put a watermark on the content.
Update
You may be able to detect bit padding as well: Any "decent" CD quality file have been properly noise shaped and dithered. It's possible that signs of this will survive the up sampling process can be detected. I've neve tried that, so I don't know how feasible it is, but it sure would be interesting to try.
Comment: @lucidbrot - people upsample audio all the time, in the mistaken belief they will "gain something". This is rarely done by experts in the field, it is usually done by people who, to put it politely, haven't a clue ;) You can expound for a long time about the 'air' above 20KHz & how it may influence perception, but how many people do you know who can hear 20KHz, or have audio equipment that could play it back? "HiFI" has more pseudo-science than science at consumer level.
Comment: @jpa oh my, people will throw machine learning at everything nowadays, no matter how nonsensical it is, won't they? There's no point in upsampling 44.1 kHz to something higher (at least not for human consumption). There's not really any point in upsampling lo-fi sample rates to 44.1 either – better to just use a good lossy compression algorithm to save bandwidth, instead of low sample rate.
Comment: Nowadays state-of-the-art is so called "audio super resolution", i.e. machine learning based upsampling. It will still show small difference is noise spectrum and stereo correlation, but it is much harder to recognize compared to traditional upsampling.
Comment: Not sure I agree with 4. If it was mastered on 30ips half inch, or even 15ips quaterter-inch, then you could always do a new transfer at whatever is today's 'popular' high-end rates. Sure, in the 80s we were mixing to Sony F1, 16-bit 44.1kHz, with zero headroom tolerance like today's structures, but there was also a 30ips safety master run simultaneously; which is actually what the record co went back to when they eventually did the iTunes digital re-masters.
Comment: @leftaroundabout if there is no reason to upsampling them, why would one care about this question anyway?
Comment: You can say in fairly certain terms that the public has no access to the original masters, so any 'hi-res' version not directly from source is usually a dodgy upsample. If you lose chain of custody along this path, then the methods proposed as an answer above come into play.
Comment: @Tetsujin Thank you for your information about the usefulness of high sample rate. What about bit depth? Is 16-bit "lossless" enough?
Comment: What tool can I use for spectral analysis? How do I look at correlation at high frequencies? How do I detect bit padding?
Comment: In your question you're talking about 'keeping a high res copy'… well that would be the original file in whatever form it was delivered. If it was 'delivered' by torrent from some dodgy no-name source, then you're back to guessing. If it was a straight CD-rip to WAV, then 16-bit 44.1kHz is your highest available format. Anything else would be just empty bits.
Answer: A file that where the signal path has been kept 96kHz from microphone to loudspeaker has the potential for signal components up to 48kHz. Most physical sound sources, rooms and microphones will roll off towards those frequencies, but slowly and gently.
If the spectrum of a 96kHz file has signs of brick-wall filtering at 22 or 24kHz, this could be a sign that somewhere in the signal chain, 44.1 or 48kHz sampling was used. It could mean that the synth used by the musician had 48kHz D/A converters.
In the end, if you cannot hear the difference, does it matter? Afaik, no-one has reliably been able to hear the degradation of a 44.1/16-bit system in fair conditions (in a way that would let you publish results in a scientific journal. Anecdotal claims about all kinds of stuff flourish among hifi people).
Answer: You could try using spectrograms to do some forensics.  I don't think there's a generalized solution, or any way to say for certain which formats can be detected as having been up sampled.  Refer to the following for nifty photos: https://sound.stackexchange.com/questions/37730/which-spectrogram-shows-higher-quality-of-the-song
MP3 works using a lossless compression scheme known as Huffman coding, which can achieve very high compression ratios when redundant data is present. An encoder might do a time-frequency analysis of the input using the MDCT-IV (I think), compare the result to psychoacoustic models, and zero out content in a way that the audible distortion is minimized.  This zeroing is what makes the compression lossy.  The more zeros, the more redundant data, the better the compression.  Note that this is very broad, and the MP3 spec/implementations are more involved.  If you look at the MP3 spectrograms in the linked answer, especially the 128kbps example, you can use visual inspection to see all the black, boxy stuff around the orangish/reddish signal.  This would suggest a lossy codec was used.  It can be a little tricky to tell, because they typically/always have a boxy quality to them, but we're looking for black/zero data where it doesn't look natural.
Upsampling the sample rate from a CD might have a similar effect.  Let's say we start with 44.1kHz and go to 192kHz. Our input has a bandwidth 22.1kHz, and the output a bandwidth of 96kHz.  The upsampler needs to figure out what to do with all that content.  A sensible approach would be to 'set' all that content to zero, so a spectrogram would show all black in that upper range.  So if we see the upper bandwidth isn't being used, that might suggest it's been upsampled from a lower rate. It might also be that the recording just had a lower bandwidth, which basically means that it could have been recorded at a lower sample rate without loss of information.  This is just a hypothetical upsampler though, there isn't international law pertaining to how it's done, and there are practical limitations to how effective the 'zeroing' is, including the cleverness of whomever designed it.
Checking for a change in bit depth is something I've not ever tried to do, but I'll hazard a guess anyway. Audible distortion from bit depth is most apparent at low signal levels, and will either manifest as harmonic distortion or noise.  I'd look for a segment where the signal fades to silence and see what's going on there.  Maybe we'd see some harmonics pop up, or some noise that doesn't seem like it should be there, and perhaps the magnitudes would give us an estimate of the bit depth.
Comment: I think the description how MP3 works is a little misleading. It doesn't really "zero out things". It reduces bit depth which generates quantization noise. The trick is to shape the quantization noise so it's below the masking threshold of the current content.
Comment: @Hilmar Yeah, I can't find my book on the subject, and reference material online is expectedly sparse. I did find this paper with a section on artifacts, which I'll want to double back on and update my answer. https://www.ee.columbia.edu/~dpwe/papers/Brand99-mp3.pdf.  It references that if the desired bit rate cannot be achieved, then high frequency content could be zeroed out, which admittedly is more of an edge case than a general statement.
Comment: @Hilmar: At least at low bitrates, DCT-based lossy compression normally does also zero some small DCT coefficients, accepting some distortion when it saves enough bitrate to be worth it.  But yes, reducing bit-depth of all the DCT coefficients is also critical; just zeroing some isn't the primary mechanism.
Comment: (This is definitely a thing in video compression, e.g. see x265's description of [psycho-visual options](https://x265.readthedocs.io/en/stable/cli.html#psycho-visual-options) lead to "fewer coefficients are zeroed by RDOQ's rate distortion analysis".  For audio, codecs like MP3 and newer (with a psycho-acoustic model) look for frequencies "masked" by louder nearby frequencies, and can fully zero those coefficients, saving bits so the audible parts don't have to be quantized as aggressively.  So I think it applies there, too.  But MP2 still did the DCT + quantization without psy stuff.)


How can a single Open Data Cube product be dumped from the index database?

Question: How can a single product be dumped from the index database to be included in another index database? I know a few Postgres commands to dump the full agdc database within the Postgres database, but the indices we are working with are becoming quite large, so being able to restore individual products without losing others (not a database overwrite - additive) would be quite useful.
Answer: You are looking to transfer products across datacubes ? Unfortunately due to how databases function and indexes being an instance specific optimisation the db server makes there is no way to transport indexes across.
If indexes are becoming an issue in a large DB it makes sense to move them to their dedicated storage media and optimise IOPs for that. See details here : https://www.cybertec-postgresql.com/en/improving-transaction-latency-by-moving-indexes-to-faster-media/
I have learnt this from bitter personal experience transporting datacubes via db dump from NCI to AWS (20+ million rows of datasets).
That said we do have some tools for persisting a collection of datasets to a  file based DB. Please see my DB backend enhancement proposal here : https://github.com/opendatacube/datacube-core/wiki/ODC-EP-004---Use-alternative-index-backends#lmdb
Answer: As @whatnick says, you can do a kind of ETL between databases, taking care to retain product and dataset relations.
Although I haven't used it, this will export metadata from an existing database.
And if you can make indexing fast enough, just doing it again is a good bet!


Doom Emacs single keystroke undo

Question: How can I have single keystroke undo using Doom Emacs with Emacs 27.2?  I have already tried multiple suggestions on this site, so far none work.  Perhaps Doom Emacs is the problem, or maybe it's that I'm using Emacs 27.2.  Is there a new solution someone can share?
Comment: Adding a link to one of the related threads:  https://emacs.stackexchange.com/q/47341/2287
Answer: It is unknown why the O.P. is experiencing problems.  The following method of installation and usage of a prior answer in a related thread appears to work correctly without any issues.
STEP #1:  Install a fresh version of Doom.  In my case, I renamed the existing ~/.emacs.d to preserve the contents and to enable git to create a new ~/.emacs.d in which to install Doom. In a terminal, run the command:
git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
STEP #2:  In the terminal, navigate with cd over to ~/.emacs.d/bin and run the command:
./doom install
Be patient while many packages are downloaded and installed.
STEP #3:  I chose y when presented with the prompt/question:
Download and install all-the-icon's fonts? (y or n)
STEP #4:  In the terminal, run the command:
./doom sync
STEP #5:  Open up ~/.emacs.d/init.el, navigate to the bottom of the file, and insert the following snippet from the answer to the related question https://emacs.stackexchange.com/a/47349/2287
(when (timerp undo-auto-current-boundary-timer)
  (cancel-timer undo-auto-current-boundary-timer))

(fset 'undo-auto--undoable-change
  (lambda () (add-to-list 'undo-auto--undoably-changed-buffers (current-buffer))))

(fset 'undo-auto-amalgamate 'ignore)

Save the file.
STEP #6:  Open or restart a recent version of Emacs, e.g., Emacs 27.2.
STEP #7:  Open a new buffer.  I am unfamiliar with vi and evil, and M-x seems to be disabled, so I used:  M-: to access eval-expression.  I typed (find-file "FOO").  I pressed the letter "i" to enable insert-mode to insert text into the current buffer.  I typed the word:  Hello.  I used the keyboard shortcut to interactively call undo-fu-only-undo, which was bound by default on OSX El Capitan to s-z.  Emacs undoes one keystroke at a time.

INSTALL NOTES:  In my case, OSX El Capitan comes with a pre-installed outdated version of Emacs at /usr/bin/emacs.  It was necessary to modify the ~/.emacs.d/bin/doom script to use a current version of Emacs, or perhaps create an alias so that the script calls to $EMACS find a recent version.  I also had to devise a method so that the files used to build Doom could find a more recent version of git.  Finally, the file +azerty.el was uncooperative with the version of wgrep that I used when trying to modify the call to "git" -- I'm not sure why the file was uncooperative, but I went ahead and deleted the extra ^M carriage returns and modified the line with "git" to use an absolute path.  However, I do not know whether that file is used when building Doom.
Comment: `s-z` was the solution.  All the Doom keybinding docs (what few correct ones there are) I've read up until now said to use `u` for undo.  Thanks!

Doom Emacs single keystroke undo


How to make a bitmap font having only a PNG file?

Question: Is there a way to "convert" an existing PNG file with the characters' images into a bitmap font? Basically, I want to create a FNT file using an image like this...

(source: opengameart.org)
...without the access to a TTF file of the image's characters or any other typical font formats.
Answer: The characters in such a monospace font are ordered in increasing ASCII codepoint row-major order.
This means that you can derive the cell offset by simple arithmetic. Given the codepoint base of the top left character, the cell index col,row of a codepoint ch is:
col= (ch-base) % columns
row= (ch-base) / columns

You can then compute X and Y of the rectangle by multiplying the cell index by the width/height of a cell.
Given the computed extents of each character, you can then emit a FNT file based on the FNT specification, or try to find a FNT generator that you can provide with input regions and a bitmap.
Comment: Good to know, I wasn't aware that the characters' order is actually according to ASCII. Still, sadly, it's not enough to easily create a bitmap font out of it - is there a tool that could process such image or do I have to write an application which could generate a FNT file according to the given sheet? Guess I'll probably have to study the FNT file structure.


Connecting flight

Question: It's my first two-step flight and I have a question.
My flight is from Warsaw to Indonesia, Denpasar with a change in Doha. Both flights take place on the Qatar Airwaves line. I have an hour and a half to change in Doha, what is the situation with my luggage? Will the carrier carry the luggage himself or do I have to pick up the luggage myself and re-send it?
Comment: Is the flight all 1 booking or did you book each leg separately?
Comment: Everything in one booking, also including flight back from Denpasar to Warsaw and another transit in Doha
Answer: If both legs of your flight are under one PNR then you will not have to pick up the luggage at Doha. The baggage will be transferred by the airline to Indonesia directly in that case.
Answer: As a general rule, on connecting flights your baggage is checked all the way to the end of the journey.
In my experience, some carriers do give you the option of collecting your luggage at each stop too, but this is optional.
If you're still unsure, you can always double check with the check in desk.
Comment: For those reading this is a different context, the biggest exception is transit in the US when arriving from abroad (except airports with pre-clearance). Of course "connecting" means on the same ticket/booking/PNR.

Connecting flight


What is the term for an image sequence with one fixed object in each image?

Question: How is it called if I have movie or image sequence in which one central object is always fixed? For example, the same car in different landscapes, the same kitchen aid in different kitchens, etc.? This is typically used for product marketing movies and I would like to know how this is called. Youtube links, etc., would be appreciated!
Comment: Relevant: https://photo.stackexchange.com/q/79739/9161
Answer: Instead of timelapse, it is more like Hyperlapse.
The difference, IMHO is that Timelapse is using a fixed camera, and hyper-lapse the camera is moving, in this case with the subjet in the same relative position.
Some tips on this other answer: How to reposition subject in the same place and pose in a series of images over time
Answer: As far as I can tell, there isn't a specific term for this, but I believe it would still be considered a time lapse, just with a static subject as the focal point.


Are there any materials that have more tensile strength than diamond?

Question: I'm looking up materials for worldbuilding, specifically for keeping metallic hydrogen in containment in zero gees. Are there any materials that have more tensile strength than a diamond anvil cell? Diamond anvil cells, from my research, have a compressive strength of about 7*10^7 atmospheres. I looked at https://www.engineeringtoolbox.com/compression-tension-strength-d_1352.html, http://www-mdp.eng.cam.ac.uk/web/library/enginfo/cueddatabooks/materials.pdf, and other websites, but none gave me materials with high strengths.
Comment: If the material is going to _contain_ something inside, then it will be under tension as the material inside tries to get out. That is different than the case of a diamond anvil cell where the diamonds are resisting being crushed (while they themselves crush the sample).
Comment: Note that a material with high compressive strength does not always have high tensile strength. For example, concrete has a high compressive strength, but breaks easily under tension (a problem that is often solved with rebar in modern construction, ensuring that the concrete is always under compressive load).
Comment: @probably_someone Yeah, I realized that when looking at diamond.
Answer: Carbon nanotubes have a theoretically extreme tensile strength, one over a thousand times the strength of diamond. Even in practice, these still have a high strengh. However, three million atmospheres of strength is the minimum pressure needed to create metallic hydrogen. This website would give you info about it1.


On a relation between the Hessian and the catalecticant matrix of a binary quartic form

Question: I am currently working on a paper that requires using the theory of invariants of binary quartic forms. Playing around, I have found an interesting identity that gives the Hessian from the minors of the catalecticant matrix of the binary quartic curve. I have not seen such relations in the reviews I have read so far, but I hope it might have a simple explanation for experts in that area. If possible, I would like to have a reference to quote in my paper and to read to educate myself.

Question Is there a simple way to see that the coefficients of the determinant of the Hessian of a binary quartic form depend linearly on the minors of the catalecticant matrix of the same binary quartic form (see theorem below)? Does it generalize to other binary form? I would be very thankful for a reference.

Background and definitions
I work over a field of characteristic zero.
A binary quartic form is a homogeneous polynomial
$$
f(x,y)= a x^4 + b x^3 y + c x^2 y^2 + d x y^3 + e y^4,
$$
with coefficient in the field.
The vector space of its covariants is generated by
$$
f(x,y), I, J, H(x,y), T(x,y),
$$
where
$$
I=12 a e-3 bd +c^2, \quad J= 72 a c e+ 9 b cd -27 a d^2 -27 e b^2 -2 c^3.
$$
are invariants and $H(x,y)$ and $T(x,y)$ are polynomial in (x,y,a,b,c,d,e). The polynomial $T(x,y)$ is of degree 6 in $x,y$ and will not be relevant here.  The polynomial $H(x,y)$ is the determinant of the Hessian (with a convenient overall coefficient):
$H(x,y)=\frac{1}{6} \Big(\frac{\partial^2 f}{\partial^2 x} \frac{\partial^2 f}{\partial^2 y}-(\frac{\partial^2 f}{\partial x \partial y})^2 \Big).$
The invariant $J$ was discovered by Cayley and is called the  catalecticant  of the binary quartic form $f$. The invariant $J$ can be expressed as a determinant of the following symmetric matrix
$$
J=det\ Cat(f)=-\frac{1}{432}\det
\begin{pmatrix}
\check{a} & \check{b} &\check{c}\\
\check{b} & \check{c} &\check{d}\\
\check{c} & \check{d} &\check{e}
\end{pmatrix},
$$
where $ \quad
\check{a} =a, \quad \check{b}=\frac{1}{4} b, \quad \check{c}=\frac{1}{6} c, \quad
\check{d}=\frac{1}{4} d, \quad
\check{e}= e.$
The following definition is introduced to simplify the theorem below.
Given a $3\times 3$ matrix M, I associate a binary quartic $f_M$ in the following way:
$
g_M(x,y)=\sum_{i,j} M_{i,j} y^{6-i-j} x^{i+j-2}.
$
In particular, if $M$ is the symmetric matrix
$$
M=\begin{pmatrix}
q_1 & q_2 & q_3 \\
q_2 & q_4 & q_5 \\
q_3 & q_5 & q_6
\end{pmatrix},$$
we have $$g_M(x,y)= q_1 y^4 +2 q_2 y^3 x + (2q_3+q_4) y^2 x^2 + 2q_5 yx^3 + q_6 x^4.
$$

Theorem:
   Let $f$ be a binary quartic form, let $M$ be the matrix of minors of $Cat(f)$,  let H$(x,y)$ be the determinant of the Hessian matrix of  $f(x,y)$,  then
  $H(x,y)=48 g_M (x,y)$.

The theorem can be proven by direct inspection since
$$M=\left(
\begin{array}{ccc}
 \frac{1}{48} \left(8 c e-3 d^2\right) & \frac{1}{48} (12 b e-2 c d) & \frac{1}{144} \left(9 b d-4 c^2\right) \\
 \frac{1}{48} (12 b e-2 c d) & \frac{1}{36} \left(36 a e-c^2\right) & \frac{1}{24} (6 a d-b c) \\
 \frac{1}{144} \left(9 b d-4 c^2\right) & \frac{1}{24} (6 a d-b c) & \frac{1}{48} \left(8 a c-3 b^2\right) \\
\end{array}
\right)
$$
and
$$
H(x,y)=x^4 (8 a c-3 b^2)-2 x^2 y^2 (-24 a e-3 b d+2 c^2)-4 x^3 y (b c-6 a d)-4 x y^3 (c d-6 b e)-y^4 (3 d^2-8 c e).
$$
Answer: I didn't check the details, but I think your construction of $g_M$ is equivariant and gives the evectant of the catalecticant (invariant) $J$. Thus you get a covariant of $f$ of degree 2 in $f$ and order 4 (the degree in the pair of variables $(x,y)$). There is only one covariant of degree-order $(2,4)$, up to scale. It is the Hessian (covariant) namely $H(x,y)$.
For a definition of evectants, see Section 5 of this article by Jaydeep Chipalkatti.
Also, remember that the minors (or rather cofactors) of a generic matrix $A$ are given by $\frac{\partial}{\partial A_{i,j}}{\rm det}(A)$.


How to view Windows' physical uptime?

Question: How can I determine how long my Windows 8.1 PC has been up and running? Checking in task manager or using systeminfo command does not work, because they do not reset when you hibernate. I need to know the time my PC is turned on, not when the last boot from a real shutdown was.
Comment: P.S. I know you can check the duration of the WiFi connection or any other network connections, but those are unreliable.
Comment: You could have a script which detects system pauses (Hibernated), and sets a timestamp, then you could have a read out showing the diff in time between now and then. But, that would only be testing for as long as the script was running, and would assume a Hibernate/Restart/Sleep if the script stops. Also, such a script would need to be running constantly. I have a set of scripts that determine network state for share creation, and it is really annoying how it is constantly in the taskbar
Answer: I created for you a custom event filter which lists events when the computer was powered on or returned from hibernate or standby. Open Event Viewer, click 'Create Custom View' and set the same as below to recreate it:

Here's an example of its output:

The 'Dhcp-client' source event is an actual full boot start-up, the others are returns from standby or hibernate.
It should also be possible to extract this data by command line, but I'm not clear if this is what you wanted.
Comment: It shows the previous system started after returning from hibernating, not the current session.
Answer: Using PowerShell:
<code>Get-WinEvent -MaxEvents 1 -FilterHashTable @{ProviderName='Microsoft-Windows-Power-Troubleshooter';LogName='System';ID='1'}
</code>
will output something like:
<code>   ProviderName: Microsoft-Windows-Power-Troubleshooter

TimeCreated                     Id LevelDisplayName Message
-----------                     -- ---------------- -------
2023/01/26 09:07:14              1 Information      The system has returned from a low power state....
</code>
Comment: This answer is more straightforward. Worked great for me. Thanks

How to view Windows' physical uptime?