How to access the current editor document from a TreeView or Webview panel in a custom VS Code extension?

Question: I would like to access the active editor document from a TreeView or Webview panel similar to how the "Outline" panel works by reading the document and providing an an easy to navigate nested tree of classes, methods and properties.
I've tried to bring the instantiated vscode.TextDocument context into each of these panel views but it only appears to be accessible to the CustomTextEditorProvider via the resolveCustomTextEditor method.
Answer: This implementation involves interacting with the VS Code API, specifically focusing on how to communicate between different parts of the extension (like TreeView, WebView, and the active text editor)
You can access the active text editor in VS Code using vscode.window.activeTextEditor. This gives you the currently focused editor, and the active text editor has a document property, which is a vscode.TextDocument. This represents the content of the currently open file.
To update your TreeView or WebView when the active editor changes, you need to listen to the onDidChangeActiveTextEditor event. Register an event listener that updates your TreeView or WebView whenever the active editor changes.
Now for communicating with TreeView or WebView
Use VS Code's messaging API to send messages between different parts of your extension. When the active editor changes, send a message to your TreeView or WebView with the necessary information extracted from the TextDocument.
In your TreeView or WebView, listen for these messages and update the view accordingly.
Implementing in WebView
WebViews are more isolated but can still communicate with the rest of your extension using message passing.
When you receive a new active document, send its content or relevant data to the WebView using postMessage.
In your WebView's JavaScript, listen for these messages and update the content.
const vscode = require('vscode');

function updateActiveDocumentContent() {
    const activeEditor = vscode.window.activeTextEditor;
    if (activeEditor) {
        const documentContent = activeEditor.document.getText();
        // Send this content to TreeView or WebView
        // For WebView: webViewPanel.webview.postMessage({ content: documentContent });
        // For TreeView: update your TreeDataProvider
    }
}

// Listen for active editor changes
vscode.window.onDidChangeActiveTextEditor(() => {
    updateActiveDocumentContent();
});

// Initial update
updateActiveDocumentContent();

Comment: Neftali, I think this is the most comprehensive explanation I've seen on the Stacks. I very much appreciate the time you spared. A++
Comment: Something I asked about [here](https://stackoverflow.com/questions/77882989/how-to-set-editor-specific-context-for-statusbar-items-in-custom-vs-code-extensi) relates to the variable `activeEditor` as being `undefined` when switching to my custom editor. Is this a known issue, expected output or an issue with my implementation?


Disproportionate of 50%-50% split for path optimizer in Journey Builder

Question:
I am trying to test out the path optimizer in JB.
There are 7 records in my DE for testing purpose (though I know it's very small number).
In my setting, I set 60% for targeting ( around 4 records) and 40% for holdback (around 3 records). Of which the 60% targeting, 50% for path A (2 records) and 50% for path B (2 records).
However, the actual split done is path A (1 record) and path B (4 records).
Does anyone has any clue of the disproportionate of 50%-50% split for path optimizer?
Answer: The answer lies in your question itself i.e., (though I know it's very small number)
The short answer/reason is:

If you are not seeing the expected distribution, increase your sample size.

More details here -->
https://help.salesforce.com/s/articleView?id=000333919&type=1
Within the Marketing Cloud May Release, Journey Builder released a new feature called the Path Optimizer that can also be considered for split testing in the Marketing Cloud. Note, the same logic applies to Path Optimizer. If you are not seeing the expected distribution, increase your sample size.
Answer: So, @VishalKumarCV is correct in the solution that your sample size is small, but the reason for this is one that is not always intuitive. So when a split is made, the percentages you see are not a guarantee, think of it more as a coin toss or a dice roll.
If you used a 6 sided dice, you would have around a 16.6% chance of getting a 1. So if you roll this die 100 times, does this guarantee you will get 16 or 17 of number 1? No it does not. Percentage is just an estimate of possibility of getting that number, the same is true with the split.
The split percentages you give are based on random assignment to see. For this example, let's assume the Split activity uses NTile() from SQL. NTile() will randomly assign a number from 1 to the max value you set in the property. So for instance if you have a 60/40 split, you would want to use an NTile(10) in a subquery and then use a CASE statement to assign to the right bucket, so for Path 1 (60%) you would want to do something like myField IN (1,2,3,4,5,6) and then myField IN (7,8,9,10) for the Path 2 (40%).
Now, the number generated is random, so it could output the number 9 50 times out of your 100 records, greatly skewing the percentage split numbers. This is why at a higher volume, that margin of error gets greatly reduced and becomes much more accurate. For example, say you only have 10 records and you push them through the above split - if you get even one that falls outside of the expected split, you are looking at a 10% shift in your split percentage. (70/30 or 50/50 etc)
Comment: Thanks Gregory, so much for explaining and sharing the detailed explanation :)


How can I use a 12 V input on a digital Arduino pin?

Question: I am creating a controller for a 12 V system using an Arduino Uno microcrontroller. For the outputs I am using a relay shield to switch the 12 V components. I have a 12 V toggle switch that turns on some 12 V components in the system and I want to use a trigger signal off of this same switch to send to an Arduino digital input. I know that the Arduino can only handle 5 V max. What would be the best way to step down the 12 V coming off of the switch to the 5 V for the input?
EDIT: The system is for use in a car. Would the amperage of the car battery need to be lowered somehow as to not blow up the components?
Comment: the amperage of the car is irrelevant - the components only use as much current as they need. The car battery is capable of supplying hundreds of Amps, such as that needed for the starter motor. This doesnt mean there is always hundreds of amps flowing and could damage things. :)
Answer: Good news! This going to be cheap! :-)

A simple resistor divider will bring the 12 V down to the 5 V an Arduino can digest. The output voltage can be calculated as
\$ V_{OUT} = \dfrac{R2}{R1+R2} V_{IN}\$
Resistor values in the range of 10 kΩ are a good choice. If your R2 is 10 kΩ then R1 should be 14 kΩ. Now 14 kΩ is not a standard value, but 15 kΩ is. Your input voltage will be 4.8 V instead of 5 V, but the Arduino will see that still as a high level. You also have a bit of headroom in case the 12 V should be a bit too high. Even 18 kΩ will still give you a sufficiently high 4.3 V, but then you have to start thinking about the 12 V a bit too low. Will the voltage still be seen as high? I would stick with the 15 kΩ.
edit
You mention an automotive environment, and then you do need some extra protection. The car's 12 V is never quite 12 V, but most of the time higher, with peaks several volts above the nominal 12 V. (Actually nominal is more like 12.9 V, at 2.15 V per cell.) You can place a 5 V zener diode in parallel with R2, and this should cut off any voltage higher than the zener's 5 V. But a zener voltage varies with the current, and at the low input current the resistors give you it will cut off at lower voltages. A better solution would be to have a Schottky diode between the Arduino's input and the 5 V supply. Then any input voltage higher than about 5.2 V will make the Schottky diode conduct, and the input voltage will be limited to the 5.2 V. You really need a Schottky diode for this, a common P-N diode has a 0.7 V drop instead of the Schottky's 0.2 V, and then the 5.7 V maximum input voltage may be too high.
Better
Michael's optocoupler is a good alternative, though a bit more expensive. You often will use an optocoupler to isolate input from output, but you can also use it to protect an input like you want here.

How it works: the input current light the internal infrared LED, which causes an output current through the phototransistor. The ratio between input and output current is called CTR, for Current Transfer Ratio. The CNY17 has a minimum CTR of 40 %, which means you need 10 mA input for 4 mA output. Let's go for the 10 mA input. Then R1 should be (12 V - 1.5 V) / 10 mA = 1 kΩ. The output resistor will have to cause a 5 V drop at 4 mA, then that should be 5 V / 4 mA = 1250 Ω. It's better to have a bit higher value, the voltage won't drop more than 5 V anyway. A 4.7 kΩ will limit the current to about 1 mA.
Vcc is the Arduino's 5 V supply, Vout goes to the Arduino's input. Note that the input will be inversed: it will be low if the 12 V is present, high when it isn't. If you don't want that, you can swap the position of the optocoupler's output and the pull-up resistor.
edit 2
How doesn't the optocoupler solution solve the overvoltage issue? The resistor divider is ratiometric: the output voltage is a fixed ration of the input. If you have calculated for 5 V out at 12 V in, then 24 V in will give 10 V out. Not OK, hence the protection diode.
In the optocoupler circuit you can see that the right side, which connects to the Arduino's input pin doesn't have any voltage higher than 5 V at all. If the optocoupler is on then the transistor will draw current, I used 4 mA in the example above. A 1.2 kΩ will cause a 4.8 V voltage drop, due to Ohm's Law (current times resistance = voltage). Then the output voltage will be 5 V (Vcc) - 4.8 V across the resistor = 0.2 V, that's a low level. If the current would be lower the voltage drop will be smaller as well, and the output voltage will rise. A 1 mA current, for instance, will cause a 1.2 V drop, and the output will be 5 V - 1.2 V = 3.8 V. The minimum current is zero. Then you don't have a voltage across the resistor, and the output will be 5 V. That's the maximum, there's nothing there which will give you a higher voltage.
What if the input voltage would become too high? You accidentally connect a 24 V battery instead of 12 V. Then the LED current will double, form 10 mA to 20 mA. The 40 % CTR will cause 8 mA output current instead of the calculated 4 mA. 8 mA through the 1.2 kΩ resistor would be a 9.6 V drop. But from a 5 V supply that would be negative, and that's impossible; you can't go lower than 0 V here. So while the optocoupler would very much like to draw 8 mA, the resistor will limit that. The maximum current through it is when the full 5 V is across it. The output will then be really 0 V, and the current 5 V / 1.2 kΩ = 4.2 mA. So whatever power supply you attach the output current won't go higher than that, and the voltage will stay between 0 V and 5 V. No further protection needed.
If you expect overvoltage you'll have to check if the optocoupler's LED can handle the increased current, but the 20 mA will not be a problem for most optocouplers (they're often rated at 50 mA maximum), and besides, that's for double input voltage, which probably won't happen IRL.
Comment: @stevenvh Thanks Steve. I look forward to returning to favor to someone that is new at electronics once I am confident with it. Thanks
Comment: The system is for use in a car. Would the amperage of the car battery need to be lowered somehow to so as to not blow up the components? I am new at this. Thanks
Comment: @D.W. Uh-oh, car! :-(. I'll update my answer.
Comment: @D.W. - No, the car battery's capacity doesn't matter. The current will be determined by the voltage (12 V) and the resistance (25 kohm in total). Then according to **Ohm's Law** the current will be 12 V / 25 kohm = 0.5 mA. It doesn't matter if the battery is a 40 Ah type or a 400 Ah type; the resistors won't allow more.
Comment: Thats great. Thanks for your help. Just curious but would something like this work? http://www.robotshop.com/ca/productinfo.aspx?pc=RB-Spa-750⟨=en-US
Comment: @D.W.: with the opto-coupler you can keep the battery separated from the Arduino, but if it is powered from the battery both grounds will be connected.
Comment: @D.W. - Yeah, seems fine. The same product can be found on the [Sparkfun site](https://www.sparkfun.com/products/9118), where there's more information, like a link to the optocoupler's datasheet. You get 2 channels, you could use the other one to sense another switched voltage if needed.
Comment: @D.W. - You're welcome. I was just thinking: do I need to add to my answer why the optocoupler is fine with a higher voltage, where the divider needed extra protection, or is that clear? Just ask if you need extra information. (Just don't ask money ;-))
Comment: @stevenvh Maybe if you dont mind as I am completly new to this amazing world of electronics. I am a Mechanical Technologist and we hardly touched anything with electrical in college let alone electronics. Thanks
Comment: @stevenvh Also just a quick question: The Arduino Uno manual says that the recomended input voltage is 7-12V and limits are 6-20V. Does that mean I can run it straight off of a the Car Battery? Thanks
Comment: @D.W. - A car's 12 V can be extremely noisy, and may have high spikes on it. To protect the Arduino's voltage regulator against these you can place a [TVS](http://en.wikipedia.org/wiki/Transient_voltage_suppression_diode) (Transient Voltage Suppressor diode) across the Arduino's power input.
Comment: Another note: many 5V devices' logical HIGH input value is something much lower than 5V -- the PIC I'm using requires only 2V to read a logic 1.  So using a simple voltage divider with, say, 4.7K and 1.8K resistors will drop 12V to 3.3V.  If you perchance get voltages up to 18V, the input to your pin will still be just below 5V.
Comment: @stevenvh thanks for that extensive answer. I was wondering if I could go with a [following](http://imgur.com/v1LdKym) circuit if I want a HIGH output for HIGH input (12V as well here but not a car :) ) The X1 connects to GND when button is pressed, Y1 is to Arduino pin.
Comment: Lol, electronics.. makes programming look really easy!
Comment: Since you have rounded-up all choices here, [there is an opinion](https://forum.arduino.cc/index.php?topic=153143.0#msg_1148863), that you just might limit the current and let AVR's clamping protection diode keep the voltage at bay. It's suggested a simple resistor of 47k - 100k in series should do that. Seems like your schottky option, but without the external schottky. Or not? Would you consider this a valid option?
Comment: also your own post here :) https://electronics.stackexchange.com/a/35817/180863 so I guess that answers the question.
Answer: A good way to isolate the 12V switch signal would be to pass it through an opto coupler. The circuit would be configured similar to the following.

Vi in the diagram represents the 12V in your circuit that is switched by your switch (S1). Select R1 to limit the current through the D1 part of the opto coupler to a level that is within the ratings of the component that you select.
Opto couplers are not the fastest components in the world, especially the cheapest ones, but for the case of a slow action like a human controlled switch, the speed of the coupler is of little concern.
Answer: For voltage independency, use a resistor to regulate the current and a Zener to regulate voltage, like this:

simulate this circuit – Schematic created using CircuitLab
With a 30k resistor, this will output 4.99V and use only about 234uA @ 12Vin.
In this case:
R1 is consuming 234uA x (12V - 4.99V) = 1.64mW
D1 is consuming 234uA x 4.99V = 1.17mW
Total power consumption: 2.81mW (when input is high)
Comment: For anything visible I would use LED + resistor divider in series to give a 5V signal at 12V and put the zener diode in parallel with the lower half of the divider and LED to protect against overvoltage. That way the LED lights up when you have an input signal and gives visual feedback.
Comment: In the above schematic set R1 to 770 Ohm and add a 330Ohm and a red LED in parallel to the Zener diode. Then at 12V input ~9mA will flow through the LED and you get a 5V output signal. If the input voltage goes up though the zener diode will limit the output signal to 5.1V and protect both the arduino and the LED.
Comment: @GoswinvonBrederlow can you please draw the circuit led/diode/resistor circuit out?
Answer: You can also use a diode and a resistor, as follows:

simulate this circuit – Schematic created using CircuitLab
I'd make the resistor something fairly stiff, otherwise you'll be sinking a lot of power from this circuit.  The beauty of this circuit (in comparison to the voltage divider) is that it doesn't care about whether your original voltage is 12V, 14V, or 15V: it will be 5V (actually 5.2-5.3V depending on the diode) regardless of the input voltage.
Comment: Careful with the overvoltage on pin absolute maximum rating. For example, ATmega32u4 datasheet: Voltage on any Pin with respect to Ground(8): -0.5V to VCC+0.5V.  If using a regular diode, voltage will be greater than VCC + 0.5V if using anything less than 170kOhm resistor. I think Schottky diodes are the safest for this.
Comment: that's quite clever, +1 for voltage independency!
Comment: You should only do this with a Schottky diode. Otherwise the high side ESD diode in the uC will potentially enter conduction before D1 does. They aren't meant for continuous operation.
Answer: A little late but in my car i use the LM7805.
Works great and is cheap.
Comment: @TonNies You got the question wrong. OP is not in search for a supply voltage for his controller. It's more about signal conditioning.
Comment: Nothing wrong with using LM7805 for level shifting 12v signals.
Comment: @chugadie: But a very uncommon and relatively "expensive" overkill approach if all you want is to bring 12V down for one IO pin.
Comment: Not as cheap as 2 resistors or a resistor and a diode.


"All The Best" vs "Best of Luck"

Question: I heard somewhere that if we wish someone younger than us then say "best of luck" and if we wish someone older than  us  then say "all the best". I don't know how much of this is true. Will you please describe the difference between the phrases and also which to use under the different contexts?
Comment: This sounds like a distinction made up by somebody desperate for a rule. The only distinction in usage I might make is to reserve _best of luck_ for cases where the person is embarking on some possibly risky experience.
Answer: As a native American English speaker, I don't know if there is much of a difference.  At the very least, no one has ever taken me to task for using either one with the inappropriate age group.
In fact, they both seem to be ellipses of the phrase I wish you all the best of luck, it just depends on where you cut the phrase.

I wish you (all the best of) luck.
I wish you all the best (of luck).
Answer: All the best is more a farewell gesture than best of luck; the former has an air of finality that the latter lacks.  If you say "all the best" to someone, there's an expectation that a significant amount of time will pass before you meet one another again.  Best of luck doesn't have such an implication, I believe; if you were to go to Vegas, and bet your life savings at the craps table on a 30:1 shot, I might say to you from sidelines, "best of luck", though I readily expect to be there comforting you in just a few moments hence.  Saying "all the best" there would sound very strange, if you knew we weren't going to part for some time.
Comment: I'm not native but I do also perceive these connotations, I can even try to explain them. "All" seems to be a lot of things to happen in a few minutes, that emphasizes the farewell sense, like wishing luck to people for *all* their lives as if you don't expect to see them ever again. "Best" emphasizes a "strong" luck that can happen in the throw of a dice, condensing luck in time.
Answer: I would say that "best of luck" would refer to something more specific, Whereas "All the best" is a generic well-wishing.

Best of luck in the new job
Best of luck with your exams
All the best for the future

etc.
So if you knew someone was having a job interview you might say "Best of luck for tomorrow!" but if you said "All the best" it would sound more like you were wishing them well for a long time - so you might say it if you didn't know when (or if) you were going to see them again. It's more an expression that you hope all goes well in their life.
I've also seen "All the best" used as a way of signing off in an email or letter (instead of "Sincerely" or "Best regards"), although it is not overly common. It would be strange to use "best of luck" here.
Answer: British English: 'All the best' is used interchangeably with 'Best regards' or 'Best wishes' or even 'Take Care' or 'Best for now' or 'Bye for now' when signing off a letter or email. It's friendlier than 'Best regards' or 'Best wishes' but not as familiar as 'Take Care'.
'Best of luck' is entirely different and specific to a need to wish someone luck because they are doing something involving some small or large risk.
Answer: I'm a British person who uses a lot of little terms and expressions probably without thinking too much about them I suppose. I use the term, "all the best", to shorten the phrase, all the best for the future, where "best of luck" is another thing altogether and just as short already.
Answer: I came to know from someone that We use the term all the best to someone with respect and best of luck as more freiendly.
Comment: This is simply an opinion. I see no difference of register between the two, at least as used in American English.

"All The Best" vs "Best of Luck"


What do the F2 drivers do after winning the championship?

Question: Each year, there will be a new Formula Two champion, but what do they do next? Take for example Oscar Piastri, who won the 2021 F2 championship. and Felipe Drugovich, who seems likely to win the 2022 F2 championship (at least for now). So, we can assume that by the end of the 2022 calendar, there will be two F2 champions that still did not get an F1 seat. So, what will happen to them if they still don't get a seat?
Answer: As of September 2022, Piastri has been confirmed to be driving in Formula One in 2023, for McLaren, while Drugovich has been confirmed as the 2022 Formula Two champion. Whether he can also make it into F1 remains to be seen.
However, there are plenty of previous examples of drivers who won the F1 feeder series (F3000/GP2/Formula 2) but never progressed into F1 itself. We can look at their career trajectories to get an idea of the options that might be available to Drugovich should he fail to break into F1:

Jorg Muller, 1996 F3000 champion. Was an F1 test driver between 1997 and 2001, while also competing in sportscar and endurance racing for BMW. Went on to have an extremely successful career in touring cars, also driving for BMW.
Bruno Junqueira, 2000 F3000 champion. Joined Champ Car for 2001, where he finished 2nd in the championship for three consecutive seasons. After Champ Car folded, he spent a season in IndyCar before moving on to endurance racing.
Bjorn Wirdheim, 2003 F3000 champion. Became Jaguar's test driver for 2004, spent a season in Champ Car in 2005, and has spent most of his career since then competing in Japan's Super GT touring car championship, with reasonable success.
Giorgio Pantano, 2008 GP2 champion. Pantano is a strange case, as he already had competed in F1, for Jordan in 2004. He spent 2009 competing in the short-lived Superleague Formula series, 2010 in the Auto GP series, and then a handful of scattered drives in the following years before his career seemingly fizzled out entirely.
Davide Valsecchi, 2012 GP2 champion. He was Lotus' test and reserve driver for 2013, but when Kimi Raikkonen was forced to miss the last two races of the season, the team elected not to promote Valsecchi and brought in Heikki Kovalainen instead. Valsecchi was highly critical of the decision, and it seemingly left him disillusioned enough to quit motorsport entirely, instead becoming a commentator for Italian TV.
Fabio Leimer, 2013 GP2 champion. Competed in the World Endurance Championship in 2014, spent 2015 as Manor Marussia's test driver as well as a brief stint in Formula E, and seemingly retired from motorsport thereafter.

So as you can see, there are plenty of options available to Drugovich should he be unable to graduate into F1, but which he will take (and, indeed, whether he will need to take them) remains to be seen.


how can I stop media scanning?

Question: I have a LG L7 mobile. From 2 days ago I have a serious problem with scanning media files. I turn on my mobile and scanning media files started scanning. after that scanning media files completed it started again and again and until know it is scanning. I do not know is it a hardware or software problem? what I have to do? please help me.
Answer: This can often be caused by filesystem corruption on the SD card. The SD card might appear to work normally if you don't access the corrupted parts of the filesystem, but since the media scanner reads the whole filesystem, it's much more likely to get stuck on a corrupted file or directory.
Try removing the SD card and using a card reader on your PC to check the filesystem (e.g. with scandisk or fsck).

how can I stop media scanning?


Not execute trigger code section if being executed from process builder context

Question: I have a before update trigger on an object which does some validations and throws .addError in certain scenarios. This object has a process builder as well which updates certain fields on object. I do not want to execute the section of code in this trigger if this is being executed during update from process builder. How to achieve this.
Answer: I would think this could work however it is al or nothing kind of solution :
In your Invocable method, when calling from the process builder pass in a true value:
public static pbStartedThis = false;

@InvocableMethod
public static void doSomething(Some value, boolean isPB){
     if(isPB == true) pbStartedThis = true;
}

Then in the trigger that you do not want to run if the PB initiated the trigger
if(ClassName.pbStartedThis) return;

This will:

Prevent the trigger from running if PB started the current iteration of the trigger
Allow you to test it by passing in true or false
Allow the trigger to run if initiated from other entry points up until the PB is executed

Note If the entry point is not from the PB but that causes the PB to fire then the trigger will not run after the PB calls the invocable method. If you need this to only happen if the PB was the entry point then you would have to use another static boolean to indicate things have started and return the evaluation of both booleans to decide to run the trigger or not.
This is off the top of my head and there may be better ways or maybe a review of the design to consider doing it completely differently.
As previously mentioned, PB and triggers should not really intersect. If either on them running depend on the other you should rethink your design as by nature the order is undetermined
Answer: I don't think there is a good way to know whether or not your trigger is being executed as a result of Process Builder. The same issue has plagued people for years with Workflow Field Updates (which are similarly difficult to know if a record is going through a trigger again because of them).
Mixing Process Builder and Triggers is a recipe for disaster, and I'd advise to choose one or the other.
If that's not a possibility, about the only suggestion I can come up with is to use a static Set<Id> in some Apex class (static variables in triggers are completely useless). In the code that you don't want to run again when the trigger is re-run after Process Builder, you would wrap the code in an if(alreadyRunSet.contains(myRec.Id)) block, and add myRec.Id to the Set<Id> somewhere inside the block.
That would cause that section of code to be run, at most, once per transaction. This method can't discriminate against how your trigger was caused to run more than once for the same record, so it would take affect for trigger interactions with other objects that invoke the trigger again, workflow rule field updates, and Process Builder.
If Process Builder is the first thing that causes this trigger of yours to run, however, then this method won't work for you because it only works to stop running code more than once.
Answer: I don't believe there is a way to check if process builder is running/executed that transaction via apex - however, you could accomplish this with small modifications to your object, process builder, and apex class/method.
First, create a new Number Field on your Object. Make it visible to all profiles, but don't put it on your page layouts. In this example I am calling my new field Workflow Update Counter
Second, update your process builder. Add a new field update to your existing updates for your Object. The field you are updating is Workflow Update Counter, and you can use the following formula as the update criteria: BLANKVALUE([YourObjectNameHere].Workflow_Update_Counter__c, 0) + 1
Lastly, update your apex method(s) and add a check to compare the newMap (or newList) with the oldMap, to check if the Workflow Update Counter field has been changed. If it has been changed, you know that your process builder ran in this transaction and you can stop it from proceeding (or do whatever other logic you want). Something like this:
if(record.Workflow_Update_Counter__c == oldMap.get(record.Id).Workflow_Update_Counter__c){
    // Since the new record and old record have the same value,
    // the process builder did not run - execute code.
    // execute your code here
}

OR
if(record.Workflow_Update_Counter__c != oldMap.get(record.Id).Workflow_Update_Counter__c){
    // the workflow counter has changed via process builder, skip this record early
    continue;
}


Applications of Rademacher's Theorem

Question: Rademacher's Theorem (that every Lipschitz function on $\mathbb{R}^{n}$ is almost everywhere differentiable) is a remarkable result on the structure of the space of Lipschitz functions, but I was wondering whether it has any interesting applications. All of the "useful" results (or maybe "applicable") that I know of about weak versions of differentiability involve estimates (e.g. Sobolev embedding, Lebesgue differentiation theorem).
Answer: I will mention seven different applications:

Characterization of almost everywhere differentiability.

The following result is a consequence of the Rademacher theorem:

Theorem (Stepanov). A function $f:\Omega\to\mathbb{R}$ defined on an open set $\Omega\subset\mathbb{R}^n$ is differentiable almost
everywhere if and only if $$ \limsup_{y\to
 x}\frac{|f(y)-f(x)|}{|y-x|}<\infty $$ for almost all $x\in\Omega$.

A beautiful proof of this classical result is given in [4].

Uniqueness of the closest point.

Let $K\subset\mathbb{R}^n$ be a compact set. For $x\in \mathbb{R}^n\setminus K$ let
$$
D_x=\{y\in K:\, d(x,y)=\operatorname{dist}(x,K)\}.
$$
If the set $D_x$ consists of one point, then it means there there is a unique point in $K$ that is closes to $x$. Unfortunately there might be points where the closest point is not unique i.e. when $D_x$ contains more than one point. For example if $K$ is a sphere centered at $x$, then $D_x=K$. However, the set of non-uniqueness points is small:

Theorem. The set of points $x\in \mathbb{R}^n\setminus K$ such that the closest point in $K$ to $x$ is not unique (i.e. $D_x$ has
more than one point) has measure zero.

Proof. Indeed, the distance function is Lipschitz and hence differentiable almost everywhere (by Rademacher). However, if the distance is differentiable at $x$, then $D_x$ consists of one point. For a proof of this fact see https://mathoverflow.net/a/299066/121665. $\Box$
For a related post see: Set of points with a unique closest point in a compact set.

Aleksandrov differentiability theorem.

Aleksandrov proved the following important result about the second order differentiability of convex functions.

Theorem (Aleksandrov).
Let $f:\mathbb{R}^n\to\mathbb{R}$ be a convex function. Then $f$ is locally Lipschitz and hence differentiable a.e. (Rademacher). Let $E\subset\mathbb{R}^n$ be the set of points where $f$ is differentiable. Then for almost all $x\in E$ there is a symmetric matrix $D^2f(x)$ such that
$$
(1)\ \ \ \ \ \ \
\lim_{y\to x}
\frac{|f(y)-f(x)-Df(x)(y-x)-\frac{1}{2}(y-x)^TD^2f(x)(y-x)|}{|y-x|^2}=0
$$
and
$$
(2)\ \ \ \ \ \ \ \ \ \ \ \ \ \
\lim_{E\ni y\to x}
\frac{|Df(y)-Df(x)-D^2f(x)(y-x)|}{|y-x|}=0.
$$

This result can be obtained from the Rademacher theorem. The idea is as follows.
The subdifferential $\partial f(x)$ is the set of all $v\in\mathbb{R}^n$ such that
$$
f(y)\geq f(x)+\langle v,y-x\rangle \
\quad
\text{for all $y\in\mathbb{R}^n$.}
$$
It is easy to prove that $\partial f(x)\neq\emptyset$ for all $x$. Let
$$
\Gamma f=\{(x,y):\, x\in\mathbb{R}^n,\ y\in \partial f(x)\}
$$
be the graph of $x\mapsto\partial f(x)$. Note that this is a multi-valued function since $\partial f(x)$ may have more than one point. However, if you apply a suitable rotation of $\Gamma f$ by $45^o$, $\Gamma f$ will became a graph of a $1$-Lipschitz function $g:\mathbb{R}^n\to\mathbb{R}^n$. Clearly $g$ is differnetiable a.e. so the graph $\Gamma f$ has tangent space almost everywhere (as isometric to the graph of $g$). Since $\Gamma f$ is more or less the graph of the gradient  $Df$, it follows that $Df$ is differentiable a.e. as stated in (2). This however, implies (1) too.
For more details, see
[AA] L. Ambrosio, G. Alberti, A geometrical approach to monotone functions in $\mathbb{R}^n$. Math Z. 230(1999), 259-316, DOI: 10.1007/PL00004691.

Non-embedding of the Heisenberg group.

Theorem (Semmes). The Heisenberg group $\mathbb{H}^n$ does not admit a bi-Lipschitz embedding not any Euclidean space.

That was observed by Semmes and it follows from a version of the Rademacher functions on the Heisenberg group proved by Pansu, see [1] page 397.
See also Non embedding of the Heisenberg group

Kirchheim-Rademacher theorem.

Suppose that $f:\Omega\to\mathbb{R}^m$ (not necessarily Lipschitz) is differentiable at $x\in\Omega$. Then
$$
\left|\frac{|f(y)-f(x)|-|Df(x)(y-x)|}{|y-x|}\right| \leq
\frac{|f(y)-f(x)-Df(x)(y-x)|}{|y-x|} \stackrel{y\to x}{\longrightarrow} 0.
$$
Observe that $\Vert z\Vert_x:=|Df(x)z|$ is a
seminorm (that mens $\Vert z_1+z_2\Vert_x\leq\Vert z_1\Vert_x+\Vert z_2\Vert_x$,
$\Vert tz\Vert_x=|t|\Vert z\Vert_x$, but $\Vert\cdot\Vert_x$ may vanish on a subspace of $\mathbb{R}^n$).

Theorem (Kirchheim). If $f:\mathbb{R}^n\supset\Omega\to X$ is a Lipschitz continuous mapping into any metric space $(X,d)$, then for
almost all $x\in\Omega$, there is a seminorm $\Vert\cdot\Vert_x$ in
$\mathbb{R}^n$ such that $$ \frac{d(f(y),f(x))-\Vert y-x\Vert_x}{|y-x|}
 \to 0 \quad \mbox{as $y\to x$.} $$

The seminorm $\Vert\cdot\Vert_x$ is called the metric derivative of $f$.
This result was proved in [2]. For another proof see [1].

Topological dimension

The following result can be proved as an application of the Kirchheim-Rademacher theorem along with the Kirchheim area formula.

Theorem. Suppose that $f:\mathbb{R}^n\supset\Omega\to X$, $\Omega$ open, is a Lipschitz continuous map onto a metric space $X$, $f(\Omega)=X$. Then $\operatorname{dim} X=n$  if and only if $\mathcal{H}^n(X)>0$.

For further comments, see Topological dimension, Hausdorff dimension, and Lipschitz mappings.

Length preserving mappings

(See also the answer of Anton Petrunin).
In  [5], Theorem 2.4.11, Gromov proved that any Riemannian manifold of dimension $n$ admits a mapping into
$\mathbb{R}^n$ that preserves lengths of curves.
Such a mapping is necessarily Lipschitz and hence differentiable almost everywhere (by Rademacher). One can prove that the Jacobian of such a mapping is different than zero almost everywhere,
and hence there is no curve-length preserving mapping into $\mathbb{R}^m$ for $m < n$. More precisely we have.

Theorem. Let $M^n$ and $N^m$ be Riemannian manifolds of dimensions $n$ and $m$ respectively. If $f:M\to N$ is a mapping that preserves length of curves, then it is Lipschitz, differentiable a.e. and $\operatorname{rank} Df= n$ a.e. In particular, we necessarily have $m\geq n$.

Proof. The fact that $f$ is Lipschitz follows from the definition of the Riemannian metric. Hence it is locally Lipschitz when represented in a local coordinate system. The map represented in a coordinate system will not necessarily preserve length, but locally it will satisfy $\ell(f\circ\gamma)\geq C\ell(\gamma)$ and it easily follows that the directional derivatives will satisfy $D_vf\geq C$ a.e. so the derivative is non-degenerate a.e. so its rank is equal $n$.

References
[1]  L. Ambrosio, B. Kirchheim, Bernd Rectifiable sets in metric and Banach spaces. Math. Ann. 318 (2000), 527–555.
[2] B. Kirchheim,
Rectifiable metric spaces: local structure and regularity of the Hausdorff measure. Proc. Amer. Math. Soc. 121 (1994), 113-123.
[3] S. Semmes, On the nonexistence of bi-Lipschitz parameterizations and geometric problems about $A_\infty$-weights. Rev. Mat. Iberoamericana 12 (1996), 337-410.
[4]  J. Maly, A simple proof of the Stepanov theorem on differentiability almost everywhere. Exposition. Math. 17 (1999), no. 1, 59–61.
[5] M. Gromov,
Partial differential relations.
Ergebnisse der Mathematik und ihrer Grenzgebiete (3)
[Results in Mathematics and Related Areas (3)], 9.
Springer-Verlag, Berlin, 1986.
Answer: The one-dimensional Rademacher differentiation theorem implies that the Cartesian product of two compact measure zero subsets of the real line is purely unrectifiable, which in turn can be used to establish the Besicovitch projection theorem, which asserts that if a subset of the plane has finite 1-dimensional Hausdorff measure and is purely unrectifiable, then almost every projection of that set to the real line has measure zero.  Thus, for instance, if one takes the Cartesian product $C \times C$ of two copies of the middle-halves Cantor set $\{0,1\} \in C = \frac{1}{4} C \cup (\frac{1}{4} C + \frac{3}{4}) \subset [0,1]$, then almost every line in the plane will fail to hit this set.  (Quantitative versions of this problem (commonly known as "Buffon's needle problem") have attracted attention in recent years, see e.g. the recent survey of Laba at https://arxiv.org/abs/1212.0247 .)
A few years ago with Hans Lindblad in https://arxiv.org/abs/1011.0949 , we used the  one-dimensional Rademacher differentiation theorem to establish that solutions to a certain nonlinear wave equation in one spatial dimension necessarily decayed to zero as time went to infinity.  This is in contrast to the linear wave equation which does not decay in one spatial dimension.  The rough idea was that if the solution did not decay, then one could show that it concentrated along a Lipschitz curve in spacetime, which by Rademacher was approximately linear at some locations and some scales, and this could be shown to be in contradiction to a certain Morawetz-type estimate on solutions to nonlinear wave equations.
One fairly well known application of the higher-dimensional Rademacher differentiation theorem is by Pansu who extended this theorem to Carnot groups, and a variant of his theory establishes the fact that if two finitely generated nilpotent groups are quasiisometric, then their associated Carnot groups are isomorphic, which is still one of the strongest statements known about quasiisometry of groups in the nilpotent case.
Answer: A Banach space is said to have the RNP provided every Lipschitz function from the line into the space has a point of differentiability.  Reflexive spaces and separable dual spaces have the RNP.  If $X$ is a separable Banach space and $Y$ has the RNP, Rademacher's theorem is used to proved that every Lipschitz function from $X$ into $Y$ is differentiable off a null set (where null set can have various meanings).  A huge number of results in nonlinear geometric functional analysis depend on this.  See the book "Geometric nonlinear functional analysis" by Benyamini and Lindenstrauss for some of them.
Comment: I used Rademacher's theorem once to define a generalization of conformal volume of orbifolds (defined by Li-Yau). The notion of conformal volume is well-defined for Lipschitz maps by Rademacher's theorem. This was useful to us, since we could estimate the conformal volume for certain Lipschitz maps (of course, they were actually piecewise smooth, but Liptschitz seemed to be the natural category of maps).
Comment: Given a bounded open set of R^n one can only stuff the interior with a countable number of cusp singularities.This follows from the Nikodym property of W^(1,p)(R^n)
Answer:
There is no path isometry $\mathbb R^2\to\mathbb R$ (search for length-preserving map in my collection);
There is no path isometry $(\mathbb R^2,\ell_p)\to\mathbb R^n$ for $p\not=2$.
Comment: Thanks. It should have occured to me that it would be natural to be able to derive nonexistence results from Rademacher.
Comment: Sir can you post the proof of there is no path isometry from R2 to R and the next statement ?
Answer: The application I am most familiar with is that it is used in the proof of the following result:
Suppose $f : \mathbb{R}^n \to \mathbb{R}$ is Lipschitz. For any $\epsilon > 0$, there exists a $C^1$ function $g$ such that the Lebesgue measure of the set { $f\neq g$ } $\cup$ { $D f \neq D g $ } is at most $\epsilon$.
One reason I know for this result being useful is that it gives the `approximate' tangent bundle structure on a countably rectifiable set:
A countably $n$-rectifiable subset of Euclidean space is usually defined as a set (almost all of) which is contained in a countable union of Lipschitz images of $\mathbb{R}^n$. The preceeding proposition is used to show that one can replace " Lipschitz images of $\mathbb{R}^n$ " with "embedded $n$-dimensional $C^1$ submanifolds" in this definition.
Since $C^1$ submanifolds have tangent spaces, one is now only a couple of checks away from the fact that one can define the intrinsic derivative of a locally Lipschitz function at almost every point of a countably rectifiable set.
Having this kind of differentiable structure for objects and functions so weak is essential for studying various GMT-esque regularity problems e.g. understanding the singularities of stationary varifolds.
Comment: You could add references to the proof. Actually it is enough to assume that the function is differentiable a.e.
Answer: The following application may not be too far outside the realm of usual applications, as described in the OP's original question statement, but I will let others decide for themselves.
Rademacher's theorem is used to prove a maximum/minimum principle for 2D drift-diffusion equations
$$\partial_t\theta + u\cdot\nabla\theta + \kappa(-\Delta)^{\gamma/2}\theta, \tag{1}$$
where $\theta:\mathbb{R}^2\rightarrow\mathbb{R}$ is a scalar-valued function, $u:\mathbb{R}^2\rightarrow\mathbb{R}^2$ is a divergence-free vector field possibly depending on $\theta$, $\kappa\geq 0$, and $(-\Delta)^{\gamma/2}$ is the fractional Laplacian of order $\gamma$. In the case where the velocity field $u$ is recovered from $\theta$ through the Biot-Savart  law
$$u = (-R_2\theta,R_1\theta),$$
where $R_1,R_2$ are the usual 2D Riesz transforms, we recover the well-known dissipative Surface Quasi-Geostrophic (SQG) equation.
When $\kappa=0$, it is easy to see from the existence of a flow map that the minimum and maximum of a smooth solution $\theta$ are conserved. For $\kappa>0$, this is no longer necessarily the case; however, the minimum is nondecreasing and the maximum is nonincreasing. To see this, one argue as follows, as for instance shown in this paper by the Cordobas. Denote the supremum $\theta$ at time $t$ respectively by
$$M(t) := \sup_{x\in\mathbb{R}^2} \theta(t,x).$$
If $\theta(0)\in L^\infty$, then since $\|\theta(t)\|_{L^p} \leq \|\theta(0)\|_{L^p}$, for any $1\leq p\leq \infty$, (see the aforementioned paper), it follows that $M(t)$ is finite. Moreover, if $\theta(t)\in \hat{L}^1$ for each $t$, then it follows from the Riemann-Lebesgue lemma that $\theta(t)\in C_0$. Hence, for each $t$, there exists a point $x(t)\in\mathbb{R}^2$ such that
$$M(t) = \theta(t,x(t)).$$
It's not hard to show that $M(t)$ is a Lipschitz continuous function. Hence by Rademacher's theorem, $M(t)$ is differentiable for almost every $t$. At such a point $t_0$ of differentiability, we can find by a compactness argument a sequence of positive numbers $h_j\rightarrow 0$ such that $x(t_0+h_j)\rightarrow x_0\in\mathbb{R}^2$ as $j\rightarrow\infty$. Since $M$ is continuous, we then have $M(t_0) = \theta(t_0,x_0)$. Now
\begin{equation*}
\begin{split}
&\frac{M(t_0+h_j)-M(t_0)}{h_j} = \frac{\theta(t_0+h_j,x(t_0+h_j))-\theta(t_0,x_0)}{h_j} \\
&=\frac{\theta(t_0+h_j,x(t_0+h_j))-\theta(t_0,x(t_0+h_j))}{h_j} + \frac{\theta(t_0,x(t_0+h_j))-\theta(t_0,x_0)}{h_j} \\
&\leq \frac{\theta(t_0+h_j,x(t_0+h_j))-\theta(t_0,x(t_0+h_j))}{h_j},
\end{split}
\end{equation*}
since the second term in the penultimate line is nonpositive. Letting $j\rightarrow\infty$ and using that $t_0$ is a point of differentiability by assumption, we obtain that
$$M'(t_0) \leq \partial_t\theta(t_0,x_0) = -u(t_0,x_0) \cdot \nabla\theta(t_0,x_0) - \kappa(-\Delta)^{\gamma/2}\theta(t_0,x_0).$$
The first term on the RHS of the preceding equality is nonpositive since $\theta(t_0)$ is maximal at $x_0$. The first term on the RHS is also nonpositive for the same reason since
$$(-\Delta)^{\gamma/2}\theta(t_0,x_0) = C_\gamma PV\int_{\mathbb{R}^2}\frac{\theta(t_0,x_0)-\theta(t_0,y)}{|x-y|^{2+\gamma}}dy.$$
Hence, $M'(t_0)\leq 0$. Note that by considering a sequence $h_j$ of negative numbers, one can show that $M'(t_0) = -\kappa(-\Delta)^{\gamma/2}\theta(t_0,x_0)$. That $m$ is nondecreasing follows by replacing $\theta$ by $-\theta$ in the preceding argument.

Applications of Rademacher's Theorem


Indirect Speech question? She said, "Let's have a beer today."

Question: What about this answer?
She suggested to have/had a beer that day.
I'm confused between have and had. Please explain?
Answer: Peter Shor posted 'I think your answer was not so much incorrect as 100 years out of date. "Suggested to go" would have been fine around 1900.' in response to a very similar question on ELU.

She suggested going for a beer that day.

is one common way of expressing this without using direct speech; another is

She suggested that we {go / should go / went} for a beer that day.

(All of these latter three alternatives are given by Quirk in ACGEL, and mentioned as being widely used by speakers of standard English by Pullum.)


About "Hybrid chord"

Question: Whats the difference in "Hybrid chord" and "Sus4" ?
And if you use Hybrid or Sus4 chord do you have to resolve to there original form ?
Answer: Berklee defines a Hybrid chord as 'A compound chord consisting of upper chord tones (except the third) and tensions above the indicated root. Also known as incomplete chords or chords without thirds.'   It gives F/G as an example.
To my mind this is a muddled concept.  Either it's 'G9sus4(omit5)' or it's 'F/G'.  If the latter, it DOES have a 3rd, in the 'F' part of the chord.   Within the terms of Berklee's definition, I suppose a sus4 chord could be considered a 'hybrid'.
But this is just Berklee, with it's 'scale-over-chord' approach to improvisation methods.  Most music is not improvised jazz.  Note Berklee's opinion and use it if you find it useful.
Anyway.  Whether you call it 'F/G', a 'hybrid' or a 'sus4', no it doesn't have to resolve to the 'non-sus' form of the chord.  Such a resolution isn't even 'expected' in the way that a dominant 7th is 'expected' to resolve to the tonic, but often doesn't.
Answer: A hybrid chord is when the upper part of the chord is different from the implied root of the chord (and I'm sure it's for the sake of making the chord easier to understand at a glance). Basically it's a slash chord but with the specific restriction of having no third.
Say musical modes were stacks of 7 Lego blocks.
Finding usable hybrid chords consists 1stly of setting aside the Root "block" & tossing out the Avoid Note(s) block(s) bc the colors don't match with the rest. From there, your available Hybrid chords are every combination to be made with the bricks left over. (Knowing available tensions for the chord you're looking at are a big part of the process.)
The root block that you set aside (but kept nearby) will form the right side of your slash symbol. The left side will be made from the chord you decided to build.
Dm7/G and FM7/G are literally both G7sus4 chords, but writing them that way is for the sake of making plain the combination of "blocks" you chose to build it with.
The numeral analysis will still be a form of V7 by nature, because that's what it is. It's just another way to spell it differently. You'd examine the individual chord tones like part of a G7sus4 chord, still.
That's why, even though it says F/G, it's still seen as not having a third: The F chord has a third, sure, but the thing to remember is that it isn't an F chord, it's a G chord in disguise.
To paraphrase a line from Berklee's Theory & Comp. 1 class: 'Unlike Hybrid chords, inverted chords have a chord tone under the slash. Hybrids have the Root under the slash.'
This page here does a good job of summarizing what I'm talking about, and has more info on top of that. https://www.thejazzpianosite.com/jazz-piano-lessons/jazz-chords/slash-chords/
Comment: How is F/G a G7sus4 chord when it has no D but an A instead? The other answer's explanation that it is a G9sus4(omit5) chord is more accurate.

About "Hybrid chord"


Can I use an existing landcover shapefile to classify a landsat image better than ROI approach?

Question: I am trying to teach myself how to develop a land surface temperature map for the first time using landsat 8 images in QGIS. I have been following an online tutorial but it seems that, when I get to the part where I need to classify landcover into different categories based on spectral signatures, it becomes very difficult to do it accurately. If I already have a shapefile of landcover that shows areas that are buildings, versus roads, versus vegetation etc. can I somehow use this?
Answer: It depends on what the next step of your workflow in generating the surface temperature map is.
Do you mean that in your tutorial the instructions are to perform supervised classification on the L8 image (e.g. using your own specification of an ROI sample)? If so, that process might produce a classified raster (that you say is inaccurate). Therefore, do you want to convert the land cover map you do have to a classified raster that is alike in form (i.e. class labels) to what would be produced in from a supervised classifier?
More details of next steps in the tutorial would help.


MySQL in visual studio express for windows phone

Question: Is there any way I could use MySQL database in Windows phone App development?? And what are the databases can be used ?
Answer: For a mobile development an embedded database like SQL Server compact or SQLite would be more appropriate. Maintain a database server inside a mobile device is not a good idea, even if it's possible.


Does nfs persisent volume mount work in a single node kubernetes cluster?If so,how?

Question: I have tried with the volume type 'Hostpath' and it worked fine.Apart from 'HostPath' are there any other volumes supporting single node cluster?
Answer: In order to create PersistentVolume(PV) and PersistentVolumeClaim(PVC) for NFS storage you can follow this Guideline, therefore I assume that it can also work with default storage class in your single node cluster.
You can also use NFS Server Provisioner as a most flexible way to implement NFS Server via Helm Chart.
Furthermore, when decision is to establish connection to the existing and functioning NFS Server, there is possibility to use NFS-Client Provisioner  Helm Chart.
If you want obtain more information about Volume Types available in Kubernetes, refer to the official Documentation.


What does it mean to give the fields energy and momentum?

Question: I am just now beginning my study of electrodynamics, and having a bit of trouble understanding the concept of giving energy and momentum to fields (specially momentum). I understand that the fields have energy and momentum in the sense that they can "offer" it to charged particles when they interact with the field; in other words, we define it as so so we can keep talking about conservation of energy and momentum like we do in other types of dynamics. But is there any other meaning to saying fields can have energy, momentum, etc other physical properties like mass (because I heard some fields can have that as well)?
Furthermore, how should I conceptualize and visualize fields having those properties, for example, having momentum?
Comment: A photon carries momentum and energy. This may help. [How can a red light photon be different from a blue light photon?](https://physics.stackexchange.com/q/540485/37364)
Answer: Fields can exert forces on charged particles.
Force by definition is the rate at which momentum changes.
Meaning when the field exerts a force on charged particles it increases its momentum, this momentum has to come from somewhere, this is why it's important to prescribe momentum to the fields.
This is especially important when there is an inherent time delay to the field. Normally you may just say "well the momentum increase on object A, comes from a decrease of momentum from object B" but because there is a delay to the field, this explanation is insufficient
Comment: Because if the momentum radiated from particle a, that is carried by the fields hasn't reached particle b yet. Then where is it?   I think you will find your answer if you search the term "Why is newtons third law violated in electrodynamics"  $$[F_{a}≠-F_{b}]$$ and as a result  $$mv_{a1} + mv_{b1} ≠ mv_{a2} + mv_{b2}$$ Mechanical momentum is not a conserved qauntity.
Comment: then the pescription of energy and momentum to fields comes purely from there being no other alternative to store the "missing energy and momentum", for the lack of a better term? Also, could you elaborate on why it is important to do so when there is a time delay? I didn't quite catch why that would be so. Thank you!
Comment: Look up griffiths Introduction to Electrodynamics, it explains it better there
Answer: Perhaps the most direct consequence is radiation pressure. While small in everyday life, it's measurable on Earth with a Nichols radiometer. In space, it's a big deal, with a substantial effect on comet tails, interplanetary trajectories, and telescope pointing.
The TESS mission occasionally sees a rather spectacular demonstration of the effect of radiation pressure in space.
Answer: As you mentioned, the energy and momentum stored in the fields can be "given back" to particles. This does make it seem like we defined field energy and momentum just for the sake of it and to keep using energy and momentum conservation, but there is more: they gravitate.
In General Relativity, the presence of energy, momentum, and stresses is what causes gravity. It is a bit more complicated than Newtonian gravity, in which everything comes from energy (which is equivalent to mass by means of $E = mc^2$). The energy, momentum, and stresses stored in the fields do gravitate, and you have, for example, the fact that a neutral particle falling into a black hole with no charge behaves differently than the same neutral particle falling on a charged black hole.
Perhaps another way of noticing how these effects are relevant is by means of the Rindler–Denur capacitor paradox, in which one computes the energy stored in a capacitor in two different reference frames in two different ways. The results ends up being inconsistent unless one takes into account the stresses caused by the field.
Answer:
What does it mean to give the fields energy and momentum?

The concept of a field in physics

In physics, a field is a physical quantity, represented by a scalar, vector, or tensor, that has a value for each point in space and time

One has to define what is mathematically represented with the term "field". For electrodynamics one has to be clear when one is discussing the pre-Maxwell or the post Maxwell view. Before the brilliant gathering of the laws of of electricity and magnetism into the classical electromagnetic theory. Before, there was no mathematical connection between light and electric and magnetic fields. Lorentz transformations and four vectors are inherent in Maxwell's theory, and it is the four vector that imposes momentum conservation in addition to energy conservation and describes mathematically electromagnetic radiation.
This link to  Feynman lectures I think makes it clear that it is the four momentum Lorentz transformation that involve momentum conservation in  classical electrodynamics.


change "shared via iOS" to "shared via

Question: I am using a SLComposeViewController to post to facebook. However all of these posts have a "shared via iOS" tag instead of "shared via my app name". Any idea how to fix this?
The stack overflow post here states this can be done by contacting developer relations. Is this really the easiest way and how would I even do that? Thanks.
Answer: It looks like this is a manual process and need to contact Facebook to do it (or the Facebook app needs to be published on the Facebook App store) according to this answer https://stackoverflow.com/a/12605241/801913
Answer: Facebook's share dialog's documentation gives a somewhat definitive answer here. You do have to contact Facebook to change the default "shared via iOS". I'm not sure what the best way to contact facebook but luckily the documentation describes some alternatives to change the post attribution. If you use Facebook's share dialog or feed dialog the post will be attributed to your app instead of iOS.

change "shared via iOS" to "shared via


Explaining The Count Sketch Algorithm

Question: Can someone explain how the Count Sketch Algorithm works? I still can't figure out how hashes are used, for example. I have a hard time understanding this paper.
Answer: This streaming algorithm instantiates the following framework.

Find a randomized streaming algorithm whose output (as a random variable) has the desired expectation but usually high variance (i.e., noise).
To reduce the variance/noise, run many independent copies in parallel and combine their outputs.

Usually 1 is more interesting than 2. This algorithm's 2 actually is somewhat nonstandard, but I'm going to talk about 1 only.
Suppose we're processing the input
a b c a b a .

With three counters, there's no need to hash.
a: 3, b: 2, c: 1

Let's suppose however that we have just one. There are eight possible functions h : {a, b, c} -> {+1, -1}. Here is a table of the outcomes.
 h  |
abc |  X = counter
----+--------------
+++ | +3 +2 +1 =  6
++- | +3 +2 -1 =  4
+-- | +3 -2 -1 =  0
+-+ | +3 -2 +1 =  2
--+ | -3 -2 +1 = -4
--- | -3 -2 -1 = -6
-+- | -3 +2 -1 = -2
-++ | -3 +2 +1 =  0

Now we can calculate expectations
            (6 + 4 + 0 + 2) - (-4 + -6 + -2 + 0)
E[h(a) X] = ------------------------------------ = 24/8 = 3
                             8

            (6 + 4 + -2 + 0) - (0 + 2 + -4 + -6)
E[h(b) X] = ------------------------------------ = 16/8 = 2
                             8

            (6 + 2 + -4 + 0) - (4 + 0 + -6 + -2)
E[h(c) X] = ------------------------------------ =  8/8 = 1 .
                             8

What's going on here? For a, say, we can decompose X = Y + Z, where Y is the change in the sum for the as, and Z is the sum for the non-as. By the linearity of expectation, we have
E[h(a) X] = E[h(a) Y] + E[h(a) Z] .

E[h(a) Y] is a sum with a term for each occurrence of a that is h(a)^2 = 1, so E[h(a) Y] is the number of occurrences of a. The other term E[h(a) Z] is zero; even given h(a), each other hash value is equally likely to be plus or minus one and so contributes zero in expectation.
In fact, the hash function doesn't need to be uniform random, and good thing: there would be no way to store it. It suffices for the hash function to be pairwise independent (any two particular hash values are independent). For our simple example, a random choice of the following four functions suffices.
abc

+++
+--
-+-
--+

I'll leave the new calculations to you.
Comment: Wow! Just a few hours of posting the question someone came up with a clearer explanation of the algorithm! Thanks so much!!! :D
Comment: Hello @insomniac. Does this mean that we need to know beforehand the set, say _O_, where a, b and c are elements of _O_?
Comment: @neilmarion It suffices to know a superset – there may be too many different items to keep a uniform random hash function. For example, if the data items are n-bit vectors, then at the outset we can choose a random n-bit vector r and let h(x) = 1 if r.x = 0 mod 2 and h(x) = -1 if r.x = 1 mod 2, where . denotes dot product.
Comment: (I'm not sure if pairwise randomness suffices to make the arguments about variance work, but that's the flavor of the hash functions that one could use.)
Comment: @insomniac Actually practical hash functions can actually easily be 'uniform random' in the sense that `P[h(x)=y]=1/u` if `1 <= y <= u`. The trouble is mutal independence, in the sense that `P[h(x_1) = y_1 and ... and h(x_n) = y_n] = P[h(x_1) = y_1]...P[h(x_n) = y_n]` which, as you say, requires `n log u` bits of memory! Luckily, as you say, we can get away with much less (four independence) for count sketches.
Answer: Count Sketch is a probabilistic data structure which allows you to answer the following question:
Reading a stream of elements a1, a2, a3, ..., an where there can be many repeated elements, you the answer to the following question at any time: How many ai elements have you seen so far?

You can clearly get an exact answer at any time just by maintaining the mapping from ai to the count of those elements you've seen so far. Recording new observations costs O(1), as does checking the observed count for a given element. However, it costs O(n) space to store this mapping, where n is the number of distinct elements.

How is Count Sketch is going to help you? As with all probabilistic data structures you sacrifice certainty for space. Count Sketch allows you to select two parameters: accuracy of the results (ε) and probability of bad estimate (δ).
To do this you select a family of d pairwise-independent hash functions. These complicated words mean that they do not collide too often (in fact, if both hashes map values onto space [0, m] then the probability of collision is approximately 1/m^2). Each of these hash functions maps the values to a space [0, w], so you create a d * w matrix.
When you read the element, you calculate each of d hashes of this element and update the corresponding values in the sketch. This part is the same for Count Sketch and Count-min Sketch.

Insomniac nicely explained the idea (calculating expected value) for Count Sketch, so I will just note that with Count-min Sketch everything is even simpler. You just calculate d hashes of the value you want to get and return the smallest of them. Surprisingly this provides a strong accuracy and probability guarantee, which you can find here.
Increasing the range of the hash functions increases the accuracy of results, while increasing the number of hashes decreases the probability of bad estimate:
ε = e/w and δ=1/e^d. Another interesting thing is that the value is always overestimated (if you found the value, it is most probably bigger than the real value, but surely not smaller).
Comment: So, both count-sketch  and min-count-sketch  algorithms solve the same problem but in a (slightly ) different way ?

Explaining The Count Sketch Algorithm


Rearrange styles in the Microsoft Word Quick Style Gallery

Question: Is there any way to re-arrange the order of the styles in Microsoft Word's Quick Style Gallery?
Answer: A Workaround
The workaround is to make a separate list somewhere, even on paper (!) or in your head, of what styles you want in the Styles Gallery and then remove everything (or nearly) and reinsert them in your desired order.
HOW TO:
Remove styles until your first choice style is at the front of the list. If necessary, remove all styles and add your first choice to be at the front. Proceed through your list, adding styles into the list in the order you desire.
Since you are identifying your top 6 or 10 styles, reinserting them into the list manually is not an onerous task.
This works if you only use your own defined styles. However, if you use some of the built-in styles, those may get bumped to the front of the list anyway. For instance, you usually only use Title once per document, so it's not really a style you might want in your "Top 5" list, unless you need to be reminded to always give your document a title. But if you add it to the Quick Styles Gallery, it will always be near the front of the list.
If the previous post is true, and it appears to be so, that it is "currently not possible" to change the priority level, that's very sad and another way that shows that Microsoft is not interested in Word being useful for professional writers and designers. (Changing the priority may be possible through editing the XML code, according to one post, but many people could not make that method work for them.)
This is a useful tool and it really should be simpler, if Word is to be a truly professional tool. Making the Style Gallery order drag-n-drop would be the "user friendly" thing to do. But since Word has far more amateur customers than professional, don't hold your breath for it being done "right".
Answer: On OS X, this cannot be done directly, but can be done through the Quick Style list.  In particular, first open the Styles Pane and then select each of the styles that you see in the Quick Style list that you no longer want there.  For each, select "Modify List" from the drop-down at the right of each style name, and then unselect "Add to Quick Style list".  Then, for each item you do want in that list, do the same thing but select "Add to Quick Style list".  To completely reorder the list, you'll need to unselect every style that shows up in the Quick Style list and then re-add them in the order you want.
Comment: This is not working for me unfortunately (Microsoft 365 Subscription)
Answer: It's currently not possible to change the priority level of a style in Word 2016 on OS X. The priority level is set based on how styles inherit from other styles and at the moment can't be set directly.
Comment: and the priority level determines where it appears in the UI?
Comment: @vy32 Apologies, I presumed you were familiar with changing the order of the styles in Word on Windows. In Windows, you can [override a style's priority](http://i.stack.imgur.com/65Qa0.png) which defines where it is positioned in the list. In OS X, it's currently not possible to manually override a style's priority.


Leave under the Cover of Darkness

Question: Why did the Jews not Leave during the Plague of Darkness they Egyptians where standing still and could not see them Leave?
Comment: Maybe the Egyptians didn't hold like the Midrash that they were paralyzed.
Answer: 1 - The time of redemption has not yet arrived.
2 - It was a much bigger miracle to leave when the Egyptians were watching, and could not stop them.
3 - The promise to Avraham Avinu of leaving with a Rechush Gadol had not been fulfilled yet.
4 - They were busy burying the Jews that died.
Comment: 5 - the same reason they didn't leave the night of Makkas Bechoros: they didn't want to leave like thieves in the night.
Answer: They weren't told to leave then.  In fact, according to the Sanhedrin 92b, some Jews (from Sheivet Ephraim) did leave early and then were killed by the Pelishtim on the way. (see also Targum Yonasan Shemos 13:17 - that the reason why Hashem did not lead the Bnei Yisrael derech Eretz Pelishtim - the land of the Pelishtim was because they massacred the Bnei Ephraim and would see the bones and flee back to Egypt).

Leave under the Cover of Darkness


Why is the air gap between the stator and rotor on a motor kept as small as it is?

Question: Between the stator windings and rotor is a small air gap. What would happen if this gap were larger than it is? Surely the magnetic field set up by energizing the stator windings would still cut the rotor and induce an emf across it. So what effect does this air gap have on the performance of the motor?
Comment: Note that it is not always kept small. Increasing the airgap is a way to reduce armature reaction without having to increase the amount of permanent magnet material. This allows for higher peak torque at the expense of efficiency. Depending on the application this may be an acceptable tradeoff.
Answer: Air has a much higher reluctance (the magnetic equivalent of resistance) than the magnetic materials used in the motor. The smaller the air gap is, the lower that reluctance, and thus the higher the magnetic flux (which is the magnetic analog of current), allowing the motor to work more efficiently and at a higher power.
Smaller air gaps also minimize leakage flux, which means more of the flux that is produced actually does something, rather than just going through the air and doing nothing to help the motor work.
Answer: Let's say you design a motor to operate at a given field strength. Most of the magnetic path reluctance comes from the air-gap. Therefore the larger the air-gap, the more H field and therefore length of magnetic material you need to establish the field, so the more expensive the motor is to make. The size and weight also go up as the amount of magnetic material.
Some motors seem to have quite a large air-gap. That comes down to cost as well. A small air-gap needs precision machining, which becomes prohibitively expensive for very small gaps. There's an optimum size of gap for any size and target market of motor that minimises the total magnet and machining costs.
Note that although this is saying the same sort of thing as Hearth's answer, it comes from a different direction.


Why do we use external pressure to find force exerted by gas on a piston in a closed vessel during its expansion?

Question: I was reading a book in which i got confused due to this. A gas is in a vessel covered by a friction-less piston. Gas pressure is more than outer atmospheric pressure (which is constant) due to which it expands. Since it expands and move the piston outward, it does work on it which is calculated by force times displacement. In finding force we use Force = Pressure times Cross section area of piston. In finding this force to calculate work why are we using Pressure on piston by atmosphere and its weight and not pressure exerted by gas. Why? Can you also tell how the correct work done by gas can be calculated.
Thanks.
Comment: Very possibly a duplicate of http://chemistry.stackexchange.com/questions/37246/work-done-by-the-system/37250#37250
Answer: For a frictionless, massless piston, the force per unit area that the gas exerts on the inner face of the piston is always equal to the force per unit area applied on the outer face of the piston (since the piston is massless, ma = 0).  However, for an irreversible process, the force per unit area exerted by the gas at the interface is composed both of the "thermodynamic pressure"  that one could determine from the equation of state for the gas (e.g., the ideal gas law) applied locally at the interface,  plus "viscous stresses" in the gas that are determined by the rate at which the gas is deforming.  Furthermore, if the expansion or compression is rapid enough, the conditions within the cylinder are not even uniform spatially.  So figuring out the force per unit area that the gas exerts at the interface for irreversible expansion is problematic.  However, fortunately, if the force per unit area on the outside is specified by manually imposing a force per unit area (e.g., if the atmosphere is imposing the pressure outside), the work done by the gas on the surroundings can still be determined.  This is because the force per unit area exerted by the gas at the interface will adjust to always match the force per unit are on the outside (again, since the piston is massless and ma = 0).
In the case of a reversible process, the situation is much simpler, since here, viscous stresses are negligible, and the force that the gas exerts per unit area on the inner face of the piston can be determined by applying the ideal gas law (or real gas equation of state) to the spatially homogeneous gas in the cylinder.  In this case, however, the force imposed on the outside must be controlled very carefully, so that it differs only slightly from the average inside gas pressure during the entire expansion or compression (and the gas pressure within the cylinder remains essentially uniform spatially).
Answer:
why are we using Pressure on piston by atmosphere and its weight and not pressure exerted by gas.

Because the gas is expanding against the atmosphere. Put yourself in the shoes of the gas. Imagine that you're inside that container, trying to push the piston outwards. What are you pushing it against? The external pressure, right? The work done by the gas is, essentially, how much effort you are putting into pushing out the piston.

Can you also tell how the correct work done by gas can be calculated.

Since you're reading about work done, whatever book you are reading should really have a formula telling you that the work done by the gas is:
$$w = \int_1^2\!\mathrm{đ}w = \int_1^2\!p_{ex}\,\mathrm{d}V$$
where 1 and 2 are the initial and final states respectively.
Comment: +1 except for that it is recommended to use a different đ symbol for [inexact differentials](http://chemistry.stackexchange.com/a/22172/186).


No option to select home page in theme customizer

Question: My Website was working fine until yesterday and today when I tried to open it it was showing me the recent posts page not the page I set as home page. Tried to change the setting from Theme Customizer but there is no more the option to select the home page or post page. Is there a solution to this? Or should I just reinstall wordpress?
Answer: To select your home page, go to Settings -> Reading and choose from the options 'Front Page Displays` provides.
In your case, the theme may or may not have an option to choose the front page from Customizer dependent on the developer.


Dual phone SIM card - how to disable both SIM's

Question: I've a dual phone SIM card (Pocophone). How can I to disable both SIM's without power down everything?
Comment: Airplane mode..
Answer: Simply switching on Airplane/Flight mode will do the job.
Answer: Usually in dual phones in android settings there is a setting as which sim to use for call,data ,text I had such a setting in my sony xperia.I am not sure about it in other phones because my Mi A3 does not have such a setting. Look in your phone settings sim setting and there should be setting for each sim in tray.
If you have such a setting then only you can disable both sim the way you want to.


Which legendary is extremely hard to catch without using the Master Ball?

Question: In Pokemon Black/White, Reshiram and Zekrom are very easy to capture using Dusk Balls. Usually I can get them in one or 2 shots. With all the other legendaries, I seem to capture them very easily as well. But is there one in particular that just can't be captured without having to use the master ball? It almost seems like a waste just sitting there in my items.
Comment: [Rattata](http://www.youtube.com/watch?v=I8mKsyRTWEI)
Comment: You're currently asking for a recommendation.  You may want to reword the question to ask, "Which legendary is extremely hard to catch without using the Master Ball?".  You'll get the same answers, and the question won't sound like a recommendation.
Comment: @fbueckert `But is there one in particular that just can't be captured without having to use the master ball?`. Pretty easy to see that's the question.
Comment: @danRhul The title sounded like a recommendation question.  That will cause kneejerk down and close votes.  Since we don't want that happening, it's better to re-word the title.
Comment: @fbueckert Just saw pre-edit. Apologies
Answer: All legendaries can be caught with relative ease without using a Masterball. However, there are some that are particularly more annoying to catch without one.
Stationary legendaries (those that sit in a single location until you catch/defeat them) are often far easier to catch without a Master Ball. If only for the fact that you can save while standing right in front of them, and then reset the system and load your save file from right before the battle if things did not go well in the previous attempt (errant criticals, foe used a self damaging move, ran out of pokeballs).
Roaming legendaries are often some of the more problematic ones. They will attempt to flee constantly unless you have a Pokemon with a move or ability that will shut that right down like Arena Trap (Useless against flying/levitating), Shadow tag, Mean Look, Wrap, etc. Gen II's legendary roaming dogs were particularly annoying because not only did they flee, they had Roar, forcing your Pokemon to flee. However, roaming Pokemon do not heal between battles, so as long as you don't mind chasing them down over and over again, a single Pokemon with False Swipe can bring them permanently down to 1 HP, and then you just throw pokeballs at them every subsequent time you encounter them.
As far as Gen V goes, I personally would (and have) used it solely for Tornadus (Black) or Thundurus (White), as just capturing your version's roamer the second it is encountered is far less hassle than chasing it down several times. Victini, Cobalion, Terrakion, Virizion, Landorus, and Kyurem, while all having the same catch rate of 3, are all stationary, and as long as you save before facing them and have a Pokemon or two that can take a few of their hits, and inflict a status ailment, can be caught with a little luck and enough regular pokeballs.
All that said, do keep in mind each pokemon's catch rate and use a calculator to figure out what that catch rate means (or do the math yourself). A frozen Tornadus at 1 HP using a Dusk Ball at an ideal time of day still only has a 9% chance of being caught. Per ball.


Why is there no first Sunday of Ordinary Time?

Question: After the Baptism of the Lord, there's the second Sunday of Ordinary Time. What happened to the first Sunday of Ordinary Time?
Answer: The Catholic website ChurchYear.net has a good explanation, though it goes beyond what you're asking. Briefly:
The title "The Nth Sunday of" any season is short for "Sunday in the Nth week of" that season. This matches the titles given to the other days of the week: for example "Wednesday in the Third Week of Lent".
The Feast of the Epiphany of Our Lord is traditionally celebrated on the 6th of January, and the Baptism of the Lord on the following Sunday. Under certain circumstances, episcopal conferences can choose to have the Epiphany celebrated on the Sunday following January 1st (the Solemnity of Mary, Mother of God). If this is the case, and that Sunday falls on or before the 6th, the Baptism of the Lord is to be celebrated on the following Sunday - on its traditional day. If, however, that first Sunday falls on the 7th or 8th (the last possible date), Epiphany is celebrated on that day (while others are celebrating the Baptism of the Lord) and the Baptism of the Lord itself is celebrated in these dioceses on the following day, Monday the 8th or 9th.
If this seems complicated, it is. But the takeaway is that the Christmas season ends with the Baptism of the Lord on either a Sunday or a Monday. The following days constitute the first week of Ordinary Time - but that week doesn't begin on Sunday - the Sunday belongs to the Christmas season! Therefore, there is no "Sunday in the First Week of Ordinary Time" - no "First Sunday of Ordinary Time".
The first full week of the season is the second week, and so here we see Sunday in the Second Week of Ordinary Time - free Second Sunday of Ordinary Time.
Comment: You're welcome! I find it interesting that, although Lent never begins on a Sunday either, that gets handled a completely different way and Lent *does* have a First Sunday.
Comment: The summarized explanation in the last paragraph is exactly what I was looking for. Thanks!
Comment: **"The Feast of the Epiphany of Our Lord is traditionally celebrated on the 6th of January, and the Baptism of the Lord on the following Sunday."**  Your statement is only half true. Traditionally the Feast of the Epiphany is on January the 6th, but the traditional date for the Baptism of the Lord is January 13th. It has only been celebrated on the Sunday following the Epiphany since Pope Paul VI inaugurated the New Mass in 1969. Hardly a traditional date. At least not yet.
Answer: Why is there no first Sunday of Ordinary Time?
The First Sunday of Ordinary Time is the Feast of the Baptism of the Lord.
Being a feast, we do not call it the First Sunday of Ordinary Time, but rather the Feast of the Baptism of the Lord. This is exceeding fitting as the Baptism of the Lord is considered the beginning of the public life of Jesus.

535 Jesus' public life begins with his baptism by John in the Jordan. John preaches "a baptism of repentance for the forgiveness of sins". A crowd of sinners - tax collectors and soldiers, Pharisees and Sadducees, and prostitutes- come to be baptized by him. "Then Jesus appears." The Baptist hesitates, but Jesus insists and receives baptism. Then the Holy Spirit, in the form of a dove, comes upon Jesus and a voice from heaven proclaims, "This is my beloved Son." This is the manifestation ("Epiphany") of Jesus as Messiah of Israel and Son of God. - Catechism of the Catholic Church

The following article explains this quite well:

Today we celebrate the Solemnity of the Baptism of Our Lord Jesus Christ and the first Sunday of the Ordinary Time. The baptism of Jesus in the Jordan River is the example of the baptism of every Christian. In this feast we see our own Baptism and we look for the correct explanation of it. Sometimes we recognize our baptism as a membership in the Church. Sometimes we regard it as a very important step of our own life. In every quest we have to come back for the truth of the Baptism. That it is the Baptism in the Christ – we have to live as Jesus lived. That it starts our spiritual life, that it is the first step in our sacramental life. We have to remember the main importance of Baptism, that in it we are saved from sins. When we live in the grace of the Baptism – that means without sin – we can be happy in our earthly and spiritual lives. - Solemnity of the Baptism of the Lord - First Sunday in Ordinary Time


Phase space formulation of Classical Electrodynamics

Question: Is there a Lorentz invariant formulation of classical electrodynamics whose source terms are the components of a phase space distribution of current densities?  I assume that from one perspective it would provide a net current density equal to an integral over all current velocities (and corresponding current densities) at each point in configuration space.  I've done a lot of searching online, but have only found articles that discuss plasma dynamics and quantum mechanics.
Comment: By phase space you mean Hamiltonian phase space?
Comment: Yes, Hamiltonian phase space, where the coordinates are, e.g., $q_{\mu}$ and $p_{\mu}$ for a set of particles; but I'm asking about a formulation in which $q_{\mu}$ and $p_{\mu}$ are components of a field vector (or tensor) and corresponding momenta respectively.
Comment: So $\mu=0,1,2,3$?
Comment: That's correct.
Answer: If we are working with potentials (developing fomulations for fields is not much more cumbersome) then the wave equation for the four-potential ($A$) is:
$\square^2 A^\nu = \mu_0 J^\nu$
With Lorentz gauge:
$\partial_\nu A^\nu =0$
Where $J^\nu$ is four-current. Let the fourier tranforms be:
$\tilde{J}^\nu \left(\mathbf{k},\omega\right) = \iiint d^3r \int cdt \exp\left(i\left(\frac{\omega}{c}\cdot ct - \mathbf{k}.\mathbf{r}\right)\right) J^\mu\left(\mathbf{r}, t\right)$
Where $c$ is the speed of light. It makes sense to switch to four-position $x^\nu = \left(ct,\mathbf{r}\right)^\mu$ and four-wavevector $k^\nu=\left(\frac{\omega}{c},\mathbf{k}\right)^\mu$. Then:
$\tilde{J}^\nu \left(k\right) = \int d^4x \exp\left(i k_\sigma x^\sigma\right) J^\mu\left(x\right)$
Same for the four-potential. Then the equations become:
$-k_\sigma k^\sigma\tilde{A}^\mu = \mu_0 \tilde{J}^\nu$
$k_\nu \tilde{A}^\nu = 0$
Is this what you were looking for? For four current we have $\partial_\nu J^\nu=0$, so $k_\sigma \tilde{J}^\sigma = 0$, thus one of the four components (e.g. charge density) can be determined from the other ones in most cases.
Comment: I think it is probably part of what I'm looking for. The momentum of a field in configuration space is the Fourier transform of the field, per "en.wikipedia.org/wiki/Position_and_momentum_space". So, I suppose a phase space density representation of a field would be the combination of the field and its Fourier transform.


Custom user profile property in SharePoint Online

Question: I need to have a property on the profiles where I would save some custom data and also have the ability to make query on this property.
I working on SP Online.
Is this possible?
Answer: This is possible also in SharePoint OnLine.
These are the steps that you have to do:

(Go to) Sharepoint Admin -> User Profiles -> Manage User Properties -> New Property

Here you have to choiche from some option.
For sure you will need to make the property indexed

Then go to Search -> Manage Search Schema -> New Managed Properties

Here you have to Add Mapping

and check the Searchable box if needed, and Retrievable option
Comment: Did this work? I have not been able to get the properties returned in search on SPO.
Comment: it does for me!
Answer: Just been puzzled by this myself and there's one more trick. Even a Full Crawl doesn't pick up the new property unless there's some data in it for at least one user.
After that, an Incremental Crawl was all I needed for it to appear in SharePoint Online.


Is any $(n-1)\times (n-1)$ submatrix of an $n \times n$ Vandermonde matrix invertible?

Question: Given an $n \times n$ vandermonde matrix $V$ which is invertible, is any $(n-1) \times (n-1)$ submatrix of $V$ invertible also?
I think the answer is yes, but I don't know how to prove.
Answer: This is an elaboration of Thierry's answer: If $0 \leq a_0 < a_1 < \cdots < a_{d-1}$ is any sequence of nonnegative integers, then the determinant $\det \left( x_j^{a_i} \right)$ is equal to $\prod_{i < j}(x_i - x_j) \cdot s_{\lambda}(x_1, \ldots, x_d)$  where $\lambda = (a_0, a_1-1, a_2-2, \ldots, a_{d-1} - (d-1))$ and $s_{\lambda}$ is the Schur function. (Wikipedia takes this as the definition of Schur functions.)
In your case, you want $(a_0, a_1, \ldots, a_d)$ to be $(0,1,2,3,\ldots, d-k-1, d-k+1, d-k+2, \ldots, d)$. The corresponding partition $\lambda$ is $(0,0,0,\ldots, 1,1,\ldots, 1)$ where there are $k$ ones. This Schur function is the elementary symmetric function
$$e_k(x) := \sum_{i_1 < i_2 < \cdots < i_k} x_{i_1} x_{i_2} \cdots x_{i_k},$$
which is apparently also known as a Veite sum.
So your minor vanishes precisely when there is a repeated column, or when $e_k$ is $0$.
Comment: Nice, I did not know there was this nice generalization. By the way, I'm not sure where the term Viète sum comes from, I'm pretty sure I learned it under a different name.
Comment: What's the meaning of $\epsilon_k(x)$?
Comment: Here $e_k$ is $\pm$ the coefficient of $t^{n-1-k}$ in $\prod_1^{n-1}(t-x_j).$
Answer: No. Take $n=2$ and $\alpha_1=0, \alpha_2=1$. Then the Vandermonde matrix
\[
 \begin{bmatrix} 1 & 0 \\\ 1 & 1 \end{bmatrix}
\]
is invertible, but the upper-right submatrix is not.
Comment: Or

$$ \begin{bmatrix} 1 & 1 & 4 \\ 1 & -1 & 2 \\ 1 & 1 & 1 \end{bmatrix} $$
Answer: Well, you're almost right... Such a determinant is sometimes known as "lacunary vandermonde" determinant, although my internet searches have not given much. Lemma 4 in this paper states that the lacunary vandermonde determinant of variables $(x_1, \dots, x_n)$ missing the terms in $x_i^k$ is obtained by a product of the regular vandermonde of $(x_1, \dots, x_n)$ times a Viete sum.
You can work out for yourself how to prove this: it's not very difficult, but it's a good exercise. The point though is that, since you assumed your vandermonde was invertible, your lacunary determinant vanishes iff the Viete sum is zero. So there is a hypersurface of possible values for  $(x_1, \dots, x_n)$ that cancel your lacunary determinant.
Answer: Recognizing the functions $e_k$ in David's excellent elaboration of Thierry's answer leads to a simple (equivalent) description and a proof for the problem considered here (but probably not the more general one of $n-1$ arbitrary powers.)
Consider the Vandermonde matrix $$V=
\begin{bmatrix}
1 & 1 & 1 & \ldots & 1 & 1 \\
x_1 & x_2 & x_3 & \ldots & x_{n-1} & t \\
x_1^2 & x_2^2 & x_3^2 & \ldots & x_{n-1}^2 &t^2 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
x_1^{n-1} & x_2^{n-1} & x_3^{n-1} & \ldots & x_{n-1}^{n-1} & t^{n-1}
\end{bmatrix}$$
Claim: The minor obtained from removing the row and column of $t^{n-1-k}$ is non-invertible exactly when the $x_i$ are the $n-1$ (distinct) roots of a polynomial $$a_0t^{n-1}+a_1t^{n-2}+\cdots+a_{n-2}t+a_{n-1}$$ with $a_k=0.$

Sketch: Think of $t$ as a variable and the various $x_j$ as parameters. The determinant is a sum of $n!$ terms each with total degree $\frac{n^2-n}{2}$ in $t$ and the $x_j$. It is also a polynomial $f(t)$ with coefficients polynomals in the $x_i$. This determinant is zero if any two of the columns are equal. Hence $f(t)$ is identically zero if any two $x_i$ are equal so $$f(t)=g(t)\prod_{0<i<j<n}(x_j-x_i)$$ Where $g(t)=e_0t^{n-1}+e_1t^{n-2}+\cdots+e_{n-2}t+e_{n-1}$ and $e_k$ has degree $k$ in the $x_j.$
Observe that

The determinant of the minor obtained by deleting the row and column of $t^{n-1-k}$ from $V\ $ is ${\displaystyle e_k \prod_{0<i<j<n}(x_j-x_i)}$
$g(t)$ is zero when $t=x_j$ so $g(t)=\prod_{0<j<n}(t-x_j)$
Put this together to establish the claim. We also see that  $$e_k(x_1,\cdots,x_{n-1}) = \sum_{0<i_1 < i_2 < \cdots < i_k<n} x_{i_1} x_{i_2} \cdots x_{i_k}.$$ (I've ignored the possible need for $\pm$ depending on the parity and order of the columns.)

Other notes:

That expression $$e_k(x_1,\cdots,x_{n-1}) := \sum_{0<i_1 < i_2 < \cdots < i_k<n} x_{i_1} x_{i_2} \cdots x_{i_k}$$ is linear in each parameter. Thus it is generally possible to choose values for any $n-2$ of the $x_j,$ along with a minor which should have determinant $0,$ and then solve uniquely for the value of remaining parameter. (I say generally because there are particular initial choices which force the minor to be singular or non-singular independent of the final value. Then a pertubation, however small, of any one chosen value restores the unique solution for the final value.)

It is worth looking at the three cases of the last row, the first row, and the other rows.

It seems that  $e_0$ would be the zero function. But one should require $k>0$ as $k=0$ corresponds to the minor which eliminates the last row. Then what remains is also a Vandermonde matrix and hence non-singular. In the polynomial form of the claim we see that there can't be enough distinct roots.
The fact that $e_{n-1} = x_1x_2x_3\cdots x_{n-1}$ corresponds to the generalization of Barts answer: If some $x_i=0$ and the minor eliminates the first row, we end up with an all zero column and a singular minor. Otherwise we can factor out $x_i \ne 0$ from each column and what remains is again a Vandermonde matrix and nonsingular.
If the minor eliminates neither the first nor the last row, then we can set the parameters to be $x_j=\exp(\frac{2\pi i j}{n-1}),$ the $n-1^{\mbox{st}}$ roots of unity, and have a singular minor since the first and last rows are identical (all 1's). For the problem considered here,  this is the only way (up to scaling) to have a repeated row. Also, this is not a different case than $e_k=0$ since we just have the roots of $t^{n-1}-1.$

That easy example is unavailable if we restrict to entries from $\mathbb{R}$ and $n>3.$  Then it is especially fortunate to have the description in terms of the $e_k.$


Refreshing SharePoint site cause the site page to go to top of window while updating at the bottom

Question: we recently came across an issue that while working on the SharePoint site, when scroll down to bottom of the page, site refresh causes the SharePoint site to get back to the top of the site thus making an issue. Is there any way to solve this type of issues in SharePoint?
Answer: Is there RichHTML field on the page? If you have one this causes setting focus on that field and no way to change this...


Cycles Glass BSDF on a Diamond viewport problem

Question: I've got an issue with my glass viewport render.
It creates some kind of a hole in that object, which looks bad. In comparison to the tutorial, with simplest nodes and everything super basic, with the same render and light paths settings, it's just totally unlike.
Of course the shape is a little bit different, but I guess it shouldn't look like that anyways..
Do you please have any ideas how to fix that?
Comment: for what it is worth, about 1/2 of all topo problems can be solved by going into edit mode, selecting all, merge by distance, recalculate normals.
Comment: Your first screenshot show the world shader.  Can you switch to Object and show the shader you're using on the diamond?  Also, check to see if all of your face normals are facing outward.  If possible, add your blend file to your question.
Comment: thanks @MartyFouts , I just updated this and here's how it looks. Simplest glass shader, the same as in the tutorial
Comment: Then I would look for differences in your lighting set up and whether or not your diamond has topology problems.  Also, did the tutorial make any changes to default rendering parameters.  This is often done when transparent objects are added to scenes.
Comment: Looks like it might be about topology.. Don't know what exactly, but it looks much better on some pre made diamond I placed with the extra add-on.
Comment: @MartyFouts that's super helpful. thanks a lot !
Answer: From my experience in Blender, a more complex diamond mesh gives the light more directions to scatter, which will increase the number of refraction effects you can detect on the surface.
In jeweler's terms, the cut of the diamond influences the clarity, sparkle, and brilliance.  Sometimes these are at odds with each other.

Also, increasing the number of Glossy and Total bounces under Light Paths will fill these dark areas with more refractions.


Unclear point in derivation of action-value function

Question: I did not understand how third equality follows from the second equality. Could some expert explain?
Answer: As $q_{\pi}(s,a)$ is defined in S&B RL book as follows:

we define the value of taking action a in state s under a policy $\pi$, denoted $q_{\pi}(s,a)$, as the expected return starting from $s$, taking the action $a$, and thereafter following policy $\pi$

Therefore similar to state value, your highlighted step here is trying to represent your action value's $\mathbb{E}_{\pi}[G_{t+1}|S_t=s,A_t=a]$ component by the state values of all possible entering states $s'$ after taking action $a$ following the same policy $\pi$ thereafter. As for the other component involving $R_{t+1}$ you've probably already known it's only determined by the environment under above conditions.


2018 BMW S1000RR hesitates when hot

Question: Recently got the bike serviced. Its done 5500 KMS. But soon after the 2nd service , I started experiencing engine hesitation issues , especially around 4 to 6000 rpm , regardless of gear. The engine stutters , almost feels like loss of power OR fuelling issues - The problem is especialy pronounced once the bike is properly HOT O in HOT condition i.e. during day time. I have also noticed , the mileage has come down a bit too. The dealer has cleaned the throttle body etc. checked on BMW diagnostics and they say , the bike is fine. But I know , its NOT fine. Any leads.
Comment: Hi and welcome.  What does "once the bike is properly HOT O in HOT condition"  mean? Please clarify
Answer: From the looks of it, this might be a fueling issue.
Can you check that your air filter is properly installed and clean and that nothing is blocking air from coming to the airbox ?
Has any modification been done to the bike ?

2018 BMW S1000RR hesitates when hot


Ubuntu media server fupah

Question: I have messed up my install of 16.04. I have made several mistakes. I had initially (not sure how) installed the system to run on the USB drive that I was using for the install. Also, the system (now 18.04 LTS) will only go through the boot menu if it is connected via LAN.
I have taken out the battery and disconnected all power connections trying to clear the MB out, and also reformatted the USB drive with another ISO of 16.04.
The system is still getting to the log-in screen and my login info does not work.
How do I blank the entire system and start over.
Answer: You will need to make install media, install Ubuntu, and select format in the setup
Make sure to install to you desired HDD. During the install, just my advice, only have the desired installation drive in your machine.
See how to make installation media and install Ubuntu here

Ubuntu media server fupah