Detect the Virtualization Layer from a guest instance(VM) - VPC or Hyper-V in C# or Powershell

Question: I want to run my application on a virtual machine but I want to know about the underlying Virtualization layer Hyper-V , VPC(Windows/Microsoft Virtual PC), or VMware.
If it is VPC i don't want to run my application.
I tried to look around here but the solution presented using WMI on WIn32_BIOS/MotherBoard doesn't differentiate between Hyper-V and VPC. I tried to see the instuction set method mentioned in the codeproject too. Is there a way to identify between the two(Hyper-V/VPC)? I don't have Hyper-V setup to test but i have Virtual PC 2007.
Comment: http://blogs.msdn.com/b/virtual_pc_guy/archive/2005/01/24/359650.aspx seems to have info that might be useful
Comment: Unless you have the additions installed you won't see this registry entry. I tried that.
Answer: Here's a Script i developed to detect this functionality
<code> Function Get-VMVirtualizationLayer{

    $Manufacturer = (Get-WmiObject win32_computersystem).manufacturer
    $model= (Get-WmiObject win32_computersystem).model
    $biosversion = (Get-WmiObject win32_bios).version

    if ($model -match "Virtual Machine")

    {

    Write-Output " Virtual Machine Running on Microsoft Virtualization Platform"

            if ($biosversion -match "VRTUAL")

            {

            Write-Output " Virtual Machine Running on Hyper-V "

            }

            elseif ($biosversion -match "A M I")

            {

            Write-Output "Virtual Machine Running on Windows Virtual PC"

            }

    }

    elseif ($model -match "VMware Virtual Platform")

    {

    Write-Output "Virtual Machine is Running on VMware Virtual Platform"

    }

    elseif ($model -match "VirtualBox")

    {

    Write-Output "Virtual Machine is Running on VirtualBox"

    }

    }

    Get-VMVirtualizationLayer
</code>
Copy Paste this entire code in an powershell prompt on the virtual machine and it would let you know the virtualization platform
Or you can copy paste the entire code into an notepad and save it as Get-VMVirtualizationLayer.ps1
Once You Run the script you would get the required output, here's the scrit output when i ran it on my Virtual Machine hosted in Hyper-V :)
<code>PS C:\INSTALL> .\Get-VMVirtualizationLayer.ps1
 Virtual Machine Running on Microsoft Virtualization Platform
 Virtual Machine Running on Hyper-V
PS C:\INSTALL>
</code>


Can air pollution negatively affect your physical performance?

Question: I've been plateaued for months. I can't increase my reps even by one more (I do, among other things, pushups with weights in a backpack, ≈30kg). Currently, I train any particular group of muscles, e.g. arms, once in three days. I tried everything I could think of (follow the link for additional information), and I recently started to wonder, what if my struggles with the sport are due to poor air quality? I live in a city with "very dirty" air, officially – near a wastewater treatment facility and coal CHP plant, at that. I've been doing daily exercises at home for years – pretty intensively if you ask me – I've breathed a lot of this bad stuff in. Can air pollution negatively affect your physical performance? What do studies say on that?
Comment: Why are you surprised that you have reach a plateau? Do you think that if you can run 100m in 12 seconds now, you can keep training and improving until you can run it in 6 seconds?
Comment: That's a great point, everyone has a physical limit too...
Comment: https://fitness.stackexchange.com/q/32237/8039 and https://fitness.stackexchange.com/q/19181/8039 may be useful.
Answer: It's never good to train on polluted places and there is a body of research showing that breathing in pollution hinders performance.
So the answer to the question based on the studies is yes, it will affect your performance.
Although to attribute your plateauing to just that, unless we are talking about incredible levels of pollution, seems unlikely.
Sometimes you need to change the exercises themselves and shake things up a little.
Also, it might be you are overtrained and need to stop for a while and deload - there are several deloading schools and you can ask about the best one for you on a different question -  but how long it's been since you've lowered your intensity?
You might need to take it easy one or two weeks to come back to increases.
Oh, and are you eating enough and sleeping well enough? Those are another important variables...
And finally, as @alephzero pointed out in the comments, there is also a genetic physical limit that we can't overcome without drugs (This is not recommending you should do drugs, at all. Just stating a documented fact)
Comment: The second reference is not available (and it's not archived by Wayback Machine). The third one is about pulmonary short-term effects after acute exposure (rather than about strength performance under chronic exposure). Thanks anyway, though
Comment: The second reference, https://apps.dtic.mil/sti/pdfs/ADA208423.pdf, I can download repeatedly. It's titled "Effects of Air Pollution on Human Exercise Performance" which is exactly what you're looking for - maybe you are on a country banned by the US military?
Comment: Well, maybe not exactly what you want, but as close as you'll get. I think the *exact study* you want about strength performance under chronic exposure has not been done yet. Hopefully someone else proves me wrong. Finally, the question you posed twice is "can air pollution negatively affect your performance?" and studies prove that it does affect it, even if not in your specific scenario.
Answer: Absolutely pollution can affect physical performance, particularly if one has an existing respiratory condition.  It might be a bit anecdotal but I can vouch that this is the case from my own experience where I have seen a coorelation between higher level of air pollutants, which I monitored, and stanima as I would struggle to breathe sufficiently much sooner where pollution levels are higher.  Over a longer time higher levels of air polution are thought to cause such respiratory problems, the effect gases like nitrogen oxides have on children linking to conditions like asthma has been the main reason to extend low emission zones to more residential areas of London.
More scientific studies are found at (for example)
https://ehp.niehs.nih.gov/doi/full/10.1289/EHP2239
https://pubmed.ncbi.nlm.nih.gov/22267572/
https://journals.sagepub.com/doi/10.1177/1757913917726567
which quite consistantly suggest a negative correlation between polution levels and performance.
Comment: Thanks, but the first one is about old folks, the second and third ones are paywalled (the last one is on how air pollution discourages exercise, not what I'm looking for)


Show PyCharm right margin?

Question: Updated from 14.04 to 14.10. Now PyCharm is starting with its vertical line in the middle of the editor. Searched the entire settings and couldn't a find solution. This article talks about disabling the "wrap-guide" or edit "stylesheet"?
Comment: This article are mainly talking about Atom Editor! and not Pycharm this code is to  Atom configuration.
Comment: What do you mean vertical line in the middle of the editor, ? There is multiple options in Pycharm where lines in the editor are optional, which one are you talking about  ?
Comment: Picture and code example in the article.
Answer: The vertical line in the picture can be disabled by going to Settings. Ctrl+Alt+S or from File -> Settings -> Editor -> General -> Unbox Right Margin
Answer: In PyCharm there is a vertical line at 120 columns to indicate a suggested maximum line length. To disable the vertical line:

Settings -> Editor -> Colors & Fonts -> General, select Right margin, uncheck the checkbox for Foreground

Show PyCharm right margin?


Fanpage: embedding an external app from a non SSL-secured source

Question: newbie here!.
I'm creating an app for a fan page to embed a Flash 'miniwebsite' in the FB page. I've been reading that it's now compulsory to have an https connection in order to show external content. Unfortunately the hosting of the external miniwebsite does not (and will not) have an SSL certificate.
Given that this app will only 'show' this external website (that is, no info/data from the visitor will be asked/required, as it's an informational site rather than a transactional site), is there any (allowed) way to use this app in the fan page without a SSL-secured source?
Alternatively, if the above is not possible, an acceptable solution for me would be if I could simply publish an image (like a 'poster') to be permanently displayed in 'a' main tab of the fan page so those users interested in visiting the website could just click on the image and be forwarded to the site. Can this be done?, and if so, how?.
Thanks a lot for your assistance.
PS: Please in your responses note that I'm a newbie in programming so be gentle! ;)
Answer: You can put up your own website that has both http/https for the authentication parts and satisfy the app settings requirement, and then from your code once authenticated, just serve the video content from the "video server".  So in effect you have a "wrapper" website around the video content.
Answer: I'm sure there is a free app to solve your problem, just search it.


Smeargle's possibility as far as Sketch

Question: Can Smeargle sketch moves but pass them to Pokemon that cant learn them legally by using the breeding system?
Answer: No, Smeargle follows the same rules for breeding as everything else, so it can only be used to pass moves that are on the child's egg move list. This is a specific list of moves for each species that are the only moves they can learn by breeding, and any other moves the parents know won't be passed down (empty move slots will be filled by the child's default level 1 moves instead).
For example, here is is a list of the egg moves for Yungoos, who is in the Field egg group like Smeargle. The moves are Revenge, Last Resort, Fire Fang, Ice Fang, and Thunder Fang - it will hatch knowing any of those moves if Smeargle (or its mother) knows them, but it will not inherit any of their other moves.

Smeargle's possibility as far as Sketch


Ratio of inductance and capacitance in Colpitts Oscillator

Question: I would like to build a Colpitts oscillator. The oscillator will have a frequency of \$f = 1/2 \pi\sqrt{C_{tot} L}\$. But what implications does my choice of \$L/C\$ have? Can I arbitrarily choose my tank circuit to be very inductive, or very capacitive? For resonators, the impedance goes as \$Z=\sqrt{L/C}\$, but it is not obvious to me how this impacts on the behavior of the oscillator.
Comment: In a colpitts oscillator the choice of capacitors determines the feedback ratio. The expression for said feedback ratio depends on the topology in use, see for instance CB, CC & CE colpitts oscillator. If the feedback ratio is too small your amplifier might not be able to sustain the oscillation. As for the inductor, don't see how it affects the rest of the circuit, except of course the resonant frequency with the formula that you've written.
Answer: It's all about being practical:
Choose your inductor so that at the desired circuit oscillation frequency, the inductor's self resonant frequency is several times higher. If you want accuracy choose an inductor that has a SRF that is ten or more times higher than the oscillation frequency. This limits the inductor to a much smaller range of acceptable values vs frequency.
At the other end of the scale, choose capacitor values that are large enough to dwarf parasitic capacitances from tracks and internal transistor capacitance.
This pretty much narrows things down to a few choices.
Answer: You know that \$X_{_\text{CT}}=\frac1{\omega_{_0}\,\cdot \,C_{_\text{T}}}\$ and that \$X_{_\text{L}}=\omega_{_0}\cdot L\$. At resonance, \$X_{_\text{CT}}=X_{_\text{L}}\$. At much lower frequencies, the tank impedance is dominated by the inductor. At much higher frequencies, the tank impedance is dominated by the capacitor. But right at that exact point, their contributions are equal and therefore the combined impedance is at its peak.
As \$X_{_\text{CT}}=X_{_\text{L}}\$, it follows that \$\frac1{\omega_{_0}\,\cdot \,C_{_\text{T}}}=\omega_{_0}\cdot L\$. So, \$\frac1{\omega_{_0}\,\cdot \,C_{_\text{T}}\,\cdot\,\omega_{_0}\cdot L}=1\$ or \$\omega_{_0}^2=\frac1{C_{_\text{T}}\,\cdot\, L}\$. That's how you get the fact that \$\omega_{_0}=\frac1{\sqrt{L\,\cdot\,C_{_\text{T}}}}\$. So, by definition, you are computing the (angular) frequency that causes the two impedances to be equal.
The combined impedance will be \$Z_{_\text{T}}=X_{_\text{CT}}\mid\mid X_{_\text{L}}\$. You can easily arrive at \$Z_{_\text{T}}=\frac12\sqrt{\frac{L}{C_{_\text{T}}}}\$, at resonance.
I don't know if you are thinking of a BJT (which works in CE, CB, and CC arrangements), JFET or opamp solutions, but in all cases of oscillation you must have positive feedback that is sufficient to sustain the oscillation. This is where you need to make sure that your loaded output feedback followed by the attenuation of the capacitive divider and its loading at the input are sufficient at the required phase.
You wrote almost nothing about what you are attempting and I am not interested in attempting to write chapter and verse on the topic, even if I could (which I could not.) So I'm stopping here.


Should I use -Sensei (先生) to refer to a teacher if they aren't my teacher?

Question: Does it make a difference whether they teach at my school, even if they don't teach my class?
Answer: As long as you are interacting with the said person in its role of teacher, you should use 先生.
Meaning that you won't if the person is your friend, family member, partner or any other relationship that doesn't involve its teacher job, even though it can still be used in this case as a joke, irony or to emphasis the teacher position.
Comment: Correct. We use 先生 only when they are in their professional capacity. This is not limited to teachers but also include such professions as lawyers and doctors that are also called 先生.
Comment: On a teacher-student situation, you can call any teacher, whether students are directly taught or not, 先生 in or outside school. The assumption is teachers always play the role of teacher at any time when they are in school or bump into a student outside school. It is only when a student has some kind of private relationship with a teacher, be it a family-to-family one or whatever, that the student might call the teacher in a different way. The main takeaway is: you can call teachers 先生 at all times.
Comment: Thank you. Suppose the person teaches at my school, doesn't teach in my class, but teaches my friend's class. Would I use 先生 then, and would it matter whether we were on school grounds or not?
Comment: I see. Would it be inappropriate NOT to use 先生 to refer to a teacher who is not my own teacher then, assuming there is no particular outside relationship between us? Suppose I run into my friend's teacher outside of school, for instance?
Answer: Additional Info:
As long as you're learning something from an entity (doesn't necessarily have to be a human being), it can be called "先生" (at least in spoken Japanese).
For example: It is very common for people to say
"Google 先生に教えてもらった" (Google sensei ni oshiete moratta)
when they learn something new via Google.


How to install Mac OS X 10.6 Snow Leopard in VMWare?

Question: I'm pretty new to Macs and would like to familiarize myself with the latest Mac OS. How do I install Mac OS X 10.6 (Snow Leopard) in VMware? Is it possible without a lot of hacking around with it?
Comment: I'm voting to close this question as off-topic because the use of OSX on non-Apple hardware is a legal grey area and as a result "Hackintosh" questions have been deemed [off-topic](http://meta.superuser.com/questions/1471/are-hackintosh-questions-allowed)
Answer: Apple licensing does not allow for the virtualization of Mac OS X Client on any hardware and only allows for the virtualization of Mac OS X Server on Apple hardware. Anything else is in violation of the license agreement.
Comment: The passage of time has rendered this answer incorrect - Since Lion, 10.7 (July 2011) it is perfectly acceptable to install OS X as a VM - **so long as that VM is running on Apple hardware**
Answer: No. Virtualization of Snow Leopard (Client) is not officially supported/allowed by any virtualization solution. (Well, at least for Leopard there were some unofficial hacks to install it with VMware Fusion but I never bothered...)
Apple does only allow virtualization of Snow Leopard Server on a Mac host. It is e.g. supported as a guest in VMware Fusion 3. But that won't help you.
Comment: Interesting - as Apple now offers MAc-Minis running Server .. should I put my pinky to my mouth and go "muahahaha" ??
Comment: You can emulate it on plain VMware workstation with "hacks". The only involvement with Fusion is that you need the VMware tools from Fusion (because it is the only officially supported way of emulating Mac on Mac), but that's about it.


Why don't we have a Temple Guard nowadays?

Question: In the Rambam's Sefer Hamitzvos, he makes clear to us that the mitzvah of guarding the Beis Hamikdash is still applicable today:

Why don't we have a Temple Guard nowadays?
Comment: IINM the brisker rav (a levi) didn't go visit the kotel lest he be obligated to remain as a gaurd
Comment: @DoubleAA If there is a mitsva and there is no one else doing it,  what difference does it make if he already goes there or not.
Answer: R. Hillel Moshe Meshil Gelbstein was the major proponent of the view that the mitzvah of guarding the Temple is still in effect today, and who campaigned to reinstate it.
In his Mishkenot LeAvir Ya'akov (Part I, p. 6) he makes the same inference as you do from Rambam's use of the word tamid:

שלשון תמיד שכתוב כאן אינו מובן בפשוטו ... א"ו [=אלא ודאי] שכוונתו גם בזה"ז [=בזמן הזה]

However, it must be noted that this position of R. Gelbstein was not accepted by the major rabbis of his day, including Aderet and R. Avraham Bornsztain (later the Sochatchover Rebbe), who partially or wholly opposed his suggested innovations. Their letters to R. Gelbstein can be found towards the beginning of Mishkenot LeAvir Ya'akov Part II.
A nice summary of the many reasons suggested to oppose R. Gelbstein's opinion can be found in R. Yechiel Michel Tucazinsky's Ir HaKodesh vehaMikdash (Vol. 4, Ch. 4).
Notably, he also quotes Sefer HaChinuch, Mitzvah 388:

ונוהגת בכהנים ולוים בזכרים בזמן הבית
And it [the mitzvah of guarding the Temple] applies during Temple times.
Comment: Did Aderet really oppose it entirely? I heard he thought it was a good idea lechumra
Comment: @DoubleAA You're right that Aderet is more ambivalent about whether the mitzvah is still in effect, although in practice he does seem to believe that guards are not necessary. I've edited to soften the language
Comment: Also worth noting the Minchas Elazar's short sefer devoted to arguing against the idea that this mitzvah applies today: https://hebrewbooks.org/pdfpager.aspx?req=14890&st=&pgnum=3
Comment: and R. Yehoshua Kutner's anti-haskamah, printed on the title page of משכנות לאביר יעקב: https://hebrewbooks.org/pdfpager.aspx?req=22469&st=&pgnum=10
Comment: Do you know exactly where the Aderet's letter is?
Comment: @wfb There are a couple printed starting from here. There may be others as well https://hebrewbooks.org/pdfpager.aspx?req=22524&st=&pgnum=19
Comment: Responsum by R Yaakov Ariel http://www.daat.ac.il/daat/kitveyet/emunat/36/03603.htm
Comment: Article by R Shaviv http://asif.co.il/?wpfb_dl=5106#_ftnref19
Answer: "Tamid" means constantly, not for all eternity. As long as the mitzva was relevant there has to be a constant honor guard, but with no Temple, the mitzva cannot be observed.
Comment: Do you have a source for this? (This is the third answer now posted here of what appears to be people making things up.)
Answer: Two reasons (there may be more)
(1) I don't see where the Rambam makes clear to us that the mitzvah of guarding the Beis Hamikdash is still applicable today. The Rambam seems to be saying the opposite.
The Rambam (Beis Habechirah 8:1)  says the guards were not security guards. They were honor guards. In the absence of the Beis Hamikdash what function would they have?  Even when the Beis Hamikdash was standing there were no guards during daytime hours (Rambam Hilchos Beis Hacheira 18:2) Some suggest that was because the Avoda gave enough  kovod that honor guards would have been superfluous.
Most of the locations the guards stood at like the gates and outside corners of the  Beis Hamikdash don't even exist anymore.
(2)The guards mentioned in the Misna  were standing on the Har HaBayis. Due to issues of Tumah we are not allowed to go on it today. In fact Rashi Bamidbar 18:2 says the  reason the Levim  stood guards to begin with was to prevent those who shouldn't be entering the area from doing so.
Comment: The places the leviim stood gaurd by definition can be accessed today, though I'm not sure why you think those locations are leikuva.
Comment: The Rambam says it is a mitzvah "tamid" - meaning, it is applicable at all times, even nowadays.
Comment: @JoelK same logic would apply for Mora Mikdash. You only have to act with fear in the place when there is a Mikdash there
Comment: The guarding is for honor, but that honor is that no tamei person should enter, and today those people and foxes are entering freely, so there should be a requirement for the guards to stand there even in the daytime.
Comment: @ShalomMeisels Maybe it is a mitzvah applicable at all times that there is a beit hamikdash there to guard
Answer: In the old translation of Perush ha-Mishnah at the beginning of Tamid, it said that this mitzvah was fulfilled in the midbar, in time of Shlomo, ועד לעולמי עד. In this translation it sounds like the mitzvah does apply at all times. However, in the Machon ha-Maor edition of the Perush ha-Mishnah, it reads: ובמהלך הדורות. This gives no indication that the mitzvah applies today.
Comment: Anyone want to check the Arabic?
Comment: @DoubleAA I don't know what the Arabic is but R. Kapach translates it as ועד סוף הדורות
Answer: Politics.
As long as the Israeli government and people are not trying to build the Beis Hamikdash, and are complaisant with the site remaining a holy site for the Muslims and effectively not for the Jews, how can we be expected to stop the wrong people from approaching? That goes against the entire idea of modern religious tolerance. And that would require a theocracy. We sold our city and religion to democracy.
Any Maccabies reading this?
Comment: I must admit though that the question is weak, as the Rambam is not clear about the mitzvah being applicable when there is no standing mikdash.
Comment: Someone needs to review Gittin 56a it sounds like
Comment: If you mean סבור רבנן לקרוביה משום שלום מלכות,
אמר רבי יוחנן ענוותנותו של רבי זכריה בן אבקולס החריבה את ביתנו, then you agree that it is a political decision, just you feel that ignoring this mitzvah is a proper decision.

Why don’t we have a Temple Guard nowadays?


text-to-speech in single purpose app/kiosk app/lock task mode

Question: In my current Android project I have to use tts (to read messages) in lock task mode (single purpose app/kiosk app). Everything works well in 'normal' app mode but when i try use text-to-speech in lock task mode then no sound comes out.
I add com.google.android.tts packake to setLockTaskPackages() but it's still not work.
Do you have any other solutions or samples usage tts in lock task mode?
Answer: Solution moved from @skajar's question post.

The solution is very easy, just don't forget to set property parameters in set User Restriction()
In my case:
setUserRestriction(UserManager.DISALLOW_MOUNT_PHYSICAL_MEDIA, false);
setUserRestriction(UserManager.DISALLOW_ADJUST_VOLUME, false);


What motion does iPhone SDK give exactly?

Question: I am a little confused about iPhone's accelerometer and gyro data. I had worked with SDK at iOS 3.x times and as far as I remember it only gives rotation around axes.
But with iPhone 4 I saw that it has a gyroscope; which is used for rotation again. If gyro is a new feature, what info does accelerometer give? I want to catch displacement of iPhone/iPod (without rotation) is there a way to catch this with any of the features?
Comment: Looks like a duplicate of this: http://stackoverflow.com/questions/3089917/gyroscope-vs-accelerometer
Answer: The 3D accelerometer in the iPhone 3G produces results that contain a mix of acceleration and orientation with respect to gravity.  It doesn't really give a great answer for either acceleration or orientation as long as the phone is in changing motion.  The Apple provided filtering algorithms only partially separate out the data, so each component can be slightly or greatly wrong.  Rotation is then estimated from any changes in the estimated direction of gravity (the down vector with respect to the device).  And estimates can be wrong.
The Core Motion API in iOS 4.x, combined with the 3 axis gyros in an iPhone 4, uses actual rotation measurements to try to subtract out rotation from the potentially mixed-up 3D accelerometer data, usually producing a much better estimates of orientation, rotation, and acceleration.
Displacement is much harder to measure, as the double integral of acceleration sums so much noise into the result, that the result will quickly diverge to be complete out of the park.
Answer: Accelerometers measure lateral acceleration whereas gyroscopes measure relative rotation.
If move your phone vertically up without rotating it, you will see a non-zero value for acceleration on one axis (assuming the device is perpendicular to the Earth) but the gyro will read 0. It sounds like you want to use only the accelerometer data.
Answer: I think you will need a gyro anyway to have a precise estimate of user acceleration and cancel gravity correctly. As usually your movement will not be just along one axis but will include slight rotation combined with slight displacement along other axises.


Make field required on condition

Question: We have 2 fields: One is a picklist (Final Status), and another is a multi-picklist (Condition for relisting).
We want to make Condition for relisting required based on the value of Final Status.
Comment: If you are asking for suggestion, You can do this with either validation rule or trigger.
Comment: can you please provide any example for the same with the help of validation rule
Answer: You can use the  rule like this...
<code>AND(ISPICKVAL(PICKLISTFIELD__c,'Yes'), ISBLANK(MULTIPICKLISTFIELD__c))
</code>
Hope this might helps...

Make field required on condition


Centre a SKLabelNode on a SKSpriteNode

Question: I have an SKLabelNode that is the child of a SKSpriteNode because I'm trying to create a Button class to create buttons in an easier way. I've tried a couple of things using the anchor point of the SKSpriteNode, but I don't quite understand exactly what is going on. How do I centre the label onto the sprite (it's parent node)?
Comment: Thanks for the quick response. I actually just figured out how to do it. I set the alignment modes (horizontal and vertical) of the label and it is perfectly centred now no matter what size the label text is! I'll post below.
Comment: I did...it's below. I answered the question myself.
Comment: If you show what you already tried, it would help us assist you.
Comment: @02fentym we wish you would have showed your code solution instead of simply expounding the fact you solved a question you asked without showing the solution.
Answer: I realized how to solve this...here's what i did. Keep in mind that I have a class called Button that is a subclass of SKSpriteNode.
In the Button.m class I have an instance variable called label that is a SKLabelNode. I add the label node as a child to the button then set the horizontal and vertical alignment modes to centre.
label = [[SKLabelNode alloc] init];
[self addChild:label];
[label setHorizontalAlignmentMode:SKLabelHorizontalAlignmentModeCenter];
[label setVerticalAlignmentMode:SKLabelVerticalAlignmentModeCenter];

Comment: OK, but how do you ensure the outer (sprite) button sprite is going to be big enough for the text?
Answer: This will put your label in center of scene in sprite kit:
yourLabel.horizontalAlignmentMode = .Center;
yourLabel.verticalAlignmentMode = .Center

Answer: Swift 4.2 XCode 10.1
Copy this function into your SpriteKit class:
func createLabel(text: String) {

    // initialisation
    let label = SKLabelNode(fontNamed: "Wicked Mouse")

    // customisation
    label.text = text
    label.fontColor = .white
    label.fontSize = 30.0

    // positioning
    label.position = CGPoint(x: self.size.width / 2, y: self.size.height / 2)
    label.verticalAlignmentMode = .center
    label.horizontalAlignmentMode = .center
    label.zPosition = 1

    self.addChild(label)

}

Comment: While this might answer the authors' question, it lacks some explaining words and/or links to documentation. Raw code snippets are not very helpful without some phrases around them. You may also find [how to write a good answer](https://stackoverflow.com/help/how-to-answer) very helpful. Please edit your answer.

Centre a SKLabelNode on a SKSpriteNode


60 V AC behind DC step-down

Question: I have various power supplies in the range of 5 V DC to 19 V DC which still have about 60 V AC pollution in their output. This makes me get zaps from the attached devices quite often. Is there a way clean the output? I'm tired of getting zapped.
Comment: How are you measuring the 60VAC - can you show a circuit and indicate the apparatus used for the measurement?
Comment: That sounds like your premises earth isn't wired up properly, or some similar line problem.
Comment: Is your AC voltage 120V?
Comment: I'd probably call an electrician on this one. Something to note is that neutral / earth problems can get worse depending on environmental factors such as soil moisture and corrosion of wiring so the annoying zap might not stay that way.
Comment: European network: 240V
Comment: Ground the output.
Answer: Assuming you have a 120VAC power feed into your premises, half that voltage "can" be seen when you haven't got a proper earth: -

simulate this circuit – Schematic created using CircuitLab
A lot of power supplies have EMI reduction circuits on input and output and these shunt switching noise to the earth line. When you don't have the earth connected properly the 120VAC supply voltage forms a capacitive potential divider with C1 and C2 - the net result is 60V AC on the earth wire and this AC inflicts itself on the DC output via C3 and C4.
EDIT - The OP has said that the incoming AC supply is 240VAC so now to justify 60VAC on the output, it is necessary to look at how this measurement is made. The same basic principle stands - the lack of earth can cause an infliction of input AC power to the output wires via the EMI protection components.

60 V AC behind DC step-down


what is the dc component in the output of diode half wave rectifier circuit will it be the average value or the rms value of the output waveform?

Question: In the book the average value is given but as it is the dc component i think it should be the rms value? Input is sine wave of amplitude 10V.
Answer: The output waveform \$v_0\$ of a half wave rectifier consists of the positive pulses of the input signal, less a bit for the diode drop.
The DC component of that is defined as its average. That's the DC value that would appear after a while on the output of a lowpass filter connected to \$v_0\$.
The RMS value of \$v_0\$ is defined as the DC value that gives the equivalent heating in the load resistor.
The difference is small but significant for modestly rippling waveforms like this. There is no difference if \$v_0\$ is DC. The difference increases as the waveform becomes more spiky.
One way to see what's happening, which I understand not everybody will grok, is that the RMS value of the waveform measures the total power that's available in all its components, AC and DC. The average value measures the power of only the DC component. The difference between the DC value and the RMS value will therefore be a measure of the power available in the non-DC components, that is the AC power of the waveform. This means that we can say that \$ RMS \ge averageDC\$, always.
If you were to connect a capacitor across the output resistor, it would hold the peak voltage of \$v_0\$, which is larger than the RMS value of the input voltage \$v_I\$, a fact that often confuses the uninitiated.
Answer: For a sinewave input: -
A perfect half wave rectifer provides only half the power to the load (compared to a straight load connection) so, square the RMS value of the sinewave, divide it by 2 and then take the square root. RMS(half wave) = \$\dfrac{V_{PEAK}}{2}\$.
For the average you need to integrate like this: -

As you can see the RMS and the average do not mathematically coincide for a sinewave.
For other input waveforms there can be equality between RMS and average or great inequalities.


What support does Ubuntu have for the Apple Magic Mouse?

Question: Does Ubuntu support the full functionality of the Apple Magic Mouse? What bluetooth adapters work best? What are the caveats?
Comment: When I connect my magic mouse it asks me for a PIN displayed on the device... that's ridiculous.
Comment: This question appears to be abandoned, if you are experiencing a similar issue please [ask a new question](http://askubuntu.com/questions/ask) with details pertaining to your problem. If you feel this question is *not* abandoned, please flag the question explaining that. :)
Answer: Please see this to get help with MultiTouch in Ubuntu: https://wiki.ubuntu.com/Multitouch#Community%20Help
There is a section dedicated to the Apple Magic Mouse, I also have that device and am interested in documenting any multitouch information there.
The above page also includes information on testing and using demos for multitouch.
If you want to see the current gestures available in Ubuntu 10.10 you will need to install the Netbook edition (Unity). On a standard desktop you don't need to reinstall, just add the ubuntu-netbook package, logout, and login again making sure you choose Ubuntu Netbook Edition at the bottom of the login screen (after choosing your user).
Answer: Ubuntu supports using it as a standard mouse (move the cursor and left/right clicks). As far as I know, all bluetooth adapters work out of the box.
The driver updates in the next version (Maverick, 10.10) are expected to support scrolling and might support multitouch.
According to this forum post someone has backported the scrolling support to Lucid, but it doesn't appear to be available in a PPA yet.


Is it possible to combine SGD/ Minibatch GD and Batch Gradient Descent to find the global optimum quickly?

Question: Say the model is bouncing around the optimum with SGD. Is there a way to know that it's near the minimum, pause the model, and continue with an extremely small learning rate
Answer: That's one of the motivations of adaptive algorithms (e.g. Adam). In this algorithms the effective learning rate change during training and adapts the local geometry of the loss surface. You can take a look at this really nice post if you want to understand this more in depth.
I see that the title of your post exposes a different problem. When you take more samples to compute one gradient update, the variance of the estimate decreases, but at the same time the complexity of each update increases. Given that the stochastic estimates are unbiased, you can go much faster using minibatch or SGD.
Now to see if you are near a minimum in a very simplistic way, you could keep track of the magnitude of the gradient. When this value is close to zero for a certain number of iterations you may take more samples into account for each gradient update.
I cannot recall any paper that uses this approach but one similar way of using "better" updates when near the optimum is to use second order methods. This approach has been largely studied, since e.g. Newton's method has the fastest convergence rate when sufficiently close to the optimum, but each update is very expensive to compute.


What is the foundation behind the concept of prayer in Hinduism?

Question: Prayer is an important concept in Hinduism. Most hindus do it. But we also believe that everything we do should have its foundations in the scriptures. So my question is, does the concept of prayer also have its foundation in the scriptures? Or is it based on something else like acharya's teachings? What are the foundations of the concept of prayer?
Comment: The answer depends on what you mean by offering prayers.. for e.g in scriptures even performing Sandhyavandanam is mentioned as an act of offering prayer.. @user15740
Comment: You have already asked similar questions on prayer isn't it?
Comment: @Rickross. Yes but all of them are about different aspects you will notice if you read it carefully.
Comment: @Rickross. Feel free to answer it if you can. Thanks.
Comment: You are asking some really nice questions!
Answer: I cannot quote scripture as I am not knowledgeable enough. This answer is partly from discourses and partly my own answer. By prayer, if you mean asking God for something good to happen or asking for relief from a bad situation then I don't think these fit in to the framework of Karma. Such prayers are part of Hinduism only because people need solace and hope.  For if God were to answer such prayers,  He clearly has to intervene in you facing Karmic consequences. Even if He does interfere, it is not clear on what basis he interfers. Millions of good people suffer and their sincere and heartfelt prayers are often not answered. The standard explanation is that it is the fruit of their Karma from an earlier birth.
On the other hand, if you mean chanting stotrams and mantras, it is possible that these are backed by scripture. One possible way by which these could give good effects is that they generate good Karma which will have effect in the future. Precisely what effect a stothram or mantram has is  usually documented in the stothram itself.  Chanting these might also produce effects that negate or neutralize existing bad Karma. Of course, stothrams are far newer than the Vedas so it is highly unlikely you will have a justification of stothram in Vedas. Of course, the standard explanation of the positive effects of Vedic chants is that the very vibrations that the chants produce is beneficial. There are also many Yagnams prescribed in the Vedas for generating good Karma. These are obviously justified in scripture.
Answer: Just to give you an example, every hymn in the Rig Veda where a god is glorified or asked to give something such as riches or protection or release from sins is one prayer.
Rig-Veda, Book 4, HYMN XXXI. Indra.
tr. by Ralph T.H. Griffith, [1896], at sacred-texts.com

Do thou who art Protector of us thy friends who praise thee
  With hundred aids approach us.
  ...
  May thine assistance keep us safe, thy hundred and thy thousand aids:
  May all thy favours strengthen us.
  ...
  Favour us, Indra, evermore with overflowing store of wealth: With all thy succours aid thou us.

Thus scriptures themselves are foundations of the concept of prayer.
Answer: I haven't read Vedas and Puranas and my answer is based on my understanding of prayers, and knowledge of Hindu philosophy. The concept of praying in modern times is heavily altered than what it is supposed to be. In modern times when you pray, you ask for something that you lack and that you wish to have so that it will fulfill your hunger of some kind. It can be the hunger for possession, knowledge, peace, or occurrence of some event, etc. It is necessary to understand that if you acquire something that you are incapable of acquiring, you won't be able to rip the benefits of it to the fullest and if you do, you will also have to suffer the underlying effects it creates due to your incapacity.

So the prayers had never been the way they are today. The way of praying in modern times is heavily influenced by the other religions that are equally prominent or simply human evolution. The chant and mantras and stotras that one is supposed to recite during worship or puja and that which is in Sanskrit or originated from Puranas like atharvashirsha, shiv manas puja, ashtakams, Chalisa etc. mainly are describing and praising the deity. It is true that chanting creates vibrations that have underlying effects on your mind, mood and on higher levels, your karma. But by continuously reciting the description of the deity, you are also expected to consciously or unconsciously know what is ideal and pick the qualities of the lord. The deities are like idols(models) or ideals or the best possible versions. while worshiping you pay respect to them by praising their qualities and try to absorb their qualities into yours. There are numerous deities in this tradition with certain specialties and they are worshiped only for a certain set of qualities. The nature of deities is very clearly defined in this culture. If you go to some astrologer or a typical Ayurveda prescriber, he will try to understand what you lack and tell you to worship a specific deity. The sole reason is to make yourself capable by engrossing that specific quality and filling the void for your well-being.
The simplest example can be seen in atharvashirsha that almost every devotee of Ganesha knows.
It starts with,

ॐ नमस्ते गणपतये ॥ (I offer salutation to lord of gana's)
  त्वमेव प्रत्यक्षं तत्वमसि ॥ (You are realization of principles)
  त्वमेव केवलं कर्तासि ॥ (You are THE creator) त्वमेव केवलं
  धर्तासि ॥ (You are THE beholder) . . ऋतम् वच्मि ॥ (I speak
  what is right) सत्यं वच्मि ॥ २॥  (I speak what is true) .
  . त्वं वाङ्मयस्त्वं चिन्मयः ॥ (you are the speech(literature),
  you are the thought(pure, ultimate, true thought or idea))
  त्वमानंदमयस्त्वं ब्रह्ममयः ॥  (you are the (supreme) bliss, you
  are the (immortal) consciousness) . . एकदन्ताय विद्महे
  वक्रतुण्डाय धीमहि । (I understand the lord (having single tusk), I
  meditate upon this lord (having curved trunk)) तन्नो दन्तिः
  प्रचोदयात् ॥१०॥  (May he grant me the knowledge and inspire me)

So the we can conclude that prayers serve following purposes:
give hope and courage
create blissful environment by chants and their vibrations
Affect your personality consciously and/or subconsciously by inspiring you

Regards.
Answer: The foundation of prayers is in the Vedas and the Upanishads. Some most beautiful prayers from these are

1.asato ma sadgamaya
tamaso ma jyotirgamaya
mrtyorma amrtam gamaya
om shanti shanti shanti.
(Lead me from the asat to the sat.
Lead me from darkness to light.
Lead me from death to immortality
Om Peace Peace Peace).
(Brhadaranyaka Upanishad — I.iii.28)
2.Tejo'si teyo mayi dhehi.
viryam asi viryam mayi dhehi.
valam asi valam mayi dhehi.
ojo'si ojo mayi dhehi.
manyur asi manyum mayi dhehi.
saho'si saho mayi dhehi
(Vajasaneya Samhita,19/9)
3. Rudra yat te dakshinam mukham tena maam paahi nityam. (Svetasvatara-Upanishad)
4.Hiranmayen paatrena satyaapihitam mukham
tat tvam pushan apaavrinu satya-dharmaaya drishtaye  (Ishopanishad).

There are innumerable beautiful prayers in the Vedas and all other scriptures.


Can someone who is eavesdropping signals from Ethernet cable, gather sensitive information

Question: Supposing I have connected my laptop to the ethernet cable and all the traffic in the ethernet cable is encrypted (let's say VPN, HTTPS, etc.). Can someone who is eavesdropping the traffic with physical access to the Ethernet cable (via an Ethernet keylogger or maybe inductively, etc), decrypt the traffic and gather sensitive information?
Comment: Why do you believe anyone would be able to decrypt the traffic?
Comment: Well, *why* do you think it would be possible? Do you believe TLS (https) is not good encryption?
Comment: Why is physical access a factor? Are you not just asking "can HTTPS be decrypted?" What is an "Ethernet keylogger"?
Comment: I think his question is more on the lines of the entire key exchange process, not just the HTTPS data traffic. Or "if I had the entire communication from start to end (including the key exchange) can I eavesdrop that encrypted communication?" but probably not aware of the asymmetric keys (or how/why it protects) used for the key exchange of the symmetric key.
Comment: The question is: Is it feasible?
Answer: No, it is not currently possible to decrypt properly encrypted traffic.
That said, if weak encryption is used, data may be at risk. Furthermore, some traffic may not actually be encrypted. For example, DNS traffic may not actually be routed over your VPN connection. This could at least disclose the domain names of the sites you are browsing to.
Answer: In order to do so, they would have to breach all the encryption methods, starting from the Layer 2 encryption (ethernet, or vpn if it runs on layer 2) and the rest. It is possible but becoming challenging with each step. As an example, if vpn is vulnerable or if the ssl website is vulnerable to attack such as  ssl stripping  or  heartbleed, then it makes it possible. If you are using openvpn, here are some of the openvpn protocol  vulnerabilities , hence that is the most popular vpn protocol. But again, every layer of encryption is a challenge.
Answer: The short answer; in theory yes, in practice no.
There's two principles you should know before I explain whats happening;
Asymmetric algorithms; public and private keys, used for the encryption and transfer of symmetric keys. https://cryptography.io/en/latest/hazmat/primitives/asymmetric/index.html
and Symmetric algorithms; typically a faster encryption however still very strong. https://cryptography.io/en/latest/hazmat/primitives/symmetric-encryption/
I'll address the two examples you question the encryption. I have access to your ethernet cable, and all the data traversing it.
You're on a VPN
A VPN connects with a asymetrical key transfer; client gives server (public) encryption key, client keeps (private) decryption key secret, server gives client it's encryption key and keeps the server's decryption secret. They then transmit a key for a "faster" encryption method through that "slower" encryption method.
You then encrypt all the network data to the VPN server with that faster encryption method. Local network header information (metadata) is not encrypted, but the VPN connection has it's own network header information in the packets data. Where it's a packet inside a packet, all that new network traffic is encrypted.
Through metadata I don't know your destination other than that VPN server, you can connect to any website or system through that network and I won't know. I just see you talking to a VPN server.
In theory, with all the time and resources in the universe, I can eventually decrypt the data. In practice however it's probably in the time frame of 8000+ years. I could target the faster encryption method where all the data is, or I could try to target the assymetrical encryption and decrypt the conversation that transmitted the symmetrical keys. Still, in practice, either is significantly difficult right now to compromise.
You're connecting to HTTPS
It's actually very similar in situ, but only the the HTTP data is encrypted.
Your browser talks to the HTTPS server with assymetrical encryption, and then transmits a symmetrical key for (faster) encryption. This can also compress the data. Then both computers transmit using the symmetrical key encryption.
I can see what site you're going to (IP Address and DNS requests), and monitor your activity (throughput), but what is being discussed and transimitted is hidden through that faster encryption. So I can see you're going to naughtysite.com and that you've downloaded 800mb of data, but I don't know what video you've watched, nor can I see the video content itself.
Again, I can attempt to attack the asymmetric keys where I'd can get the symmetric key, or just attack the symmetric key encrypted data. Both of which would take a really long time to attack. And I believe, the symmetric key may change over time throughout the connection to the server, so I may have to attack multiple symmetric keys and not know where/when in the conversation that change has happened.
Weak Encryption
So all of that assumes you're using strong encryption algorithms. There are weak algorithms no longer used in practice, primarily because they are "easy" to decrypt, or they have major flaws that are easy to break. Which is why you want to make sure you're using a VPN or HTTPS with strong encryption algorithms, but again they typically aren't used in practice, just in study. (an example off the top of my head is WEP for wifi encryption)
But that doesn't mean the encryption algorithms we use don't have a flaw we don't know about today, and next week we might find that flaw, where that once strong encryption is now broken. So everything I've captured today, I might decrypt next month.
Vulnerable Software
The remaining part of the chain is the software used to encrypt the traffic and exchange those keys. If there is a vulnerability in that software where I can compel the software to release the key to me or change the key to something I want, then I can compromise the communication and decrypt or inject data.
Comment: The answer is still "in theory yes, but not practically." With all the computing power in the world, yes eventually the data could be decrypted and "eavesdropped". Altered is a very different question, as I would need to be able to re-encrypt the data and pass any other validations in near real time.
Comment: Proxies inspect HTTPS traffic. using TLS interception
Comment: Proxy use does not meet the qualification of the question, just access to the "physical cable", presuming "data keylogger" means port mirroring, and "maybe inductively" to signal level capture decoded to just the data stream between a server and client.
Comment: Because yeah, I *could* set up a computer where I own and trust a CA, and my proxy server intercepts and forges certificates from any website using my trusted CA, and can inject keys becuase it's completely a trusted interception.
Comment: To be more precise, can data encrypted with AES (inside the ethernet cable) be eavesdropped/altered/decrypted?


a map between two expansions of a function

Question: Is there something remarkable about the following map between two kinds of expansion $f(x)=\sum_n f_n x^n$ and $\tilde{f}(x)=\sum_n \frac{f_n x^n}{n!}$ ?
Comment: @Eugene: your question seems vague.  It is possible to say *something* about the passage from an ordinary generating function to an exponential generating function, so the answer is yes.  But what is it that you really want to know?
Comment: It takes "division by x and ignoring the remainder" to differentiation; this is certainly a noteworthy algebraic property.
Comment: It can be modeled by a variation of the Laplace transform (or possibly its inverse). The details are left as an exercise...
Comment: Motivation came from the star-product (Moyal-Weyl) algebras. It turned out that certain star-product can be represented just as a pointwise multiplication of functions if one passes from one kind of expansion to another one. The map is not local, but who cares if it allows to transform complicated star-product equations to algebraic ones for functions of commuting variables.
Answer: I don't know your motivation, but the passage between the two expansions is compatible with the theory of "$q$-integers".  Recall that an integer $n$ can be written as the sum $1+1+\cdots+1$ ($n$ times).  Its "$q$-analog" is the number $[n]_q = 1 + q + \cdots + q^{n-1}$.  This is $n$ when $q=1$ and $1$ when $q=0$.
Similarly, $n!$ has a $q$-analog given by $[n]_q! = \[1\]_q \cdot [2]_q \cdots [n]_q = (1) \cdot (1+q) \cdot (1+q+q^2) \cdots (1+q+\cdots +q^n)$.  If $q=1$ this is the usual factorial, and if $q=0$ it is simply $1$.
Thus if you consider $$f_q(x) = \sum \frac{f_n}{[n]_q!} x^n,$$ then $q=0$ corresponds to your $f$ and $q=1$ to your $\tilde{f}$.
There are some surprising extensions of a number of combinatorial objects to $q\neq 1$, see for example the Wikipedia page on q-analogs. For example, if $\tilde{f}$ satisfies a differential equation, then $f$ satisfies an appropriate $q$-analog of it (this was effectively mentioned in one of the comments, as the $q$-derivative at $q=0$ is simply multiplication by $1/x$).
Comment: ? Can I define a flow with respect to q? a differential equation for the evolution in q?


Is playing carrom-board haram.?

Question: Is Playing Carrom-board Haram.? Please clarify with Hadith(if available).. Thanks in Advance
Answer: Rule of thumb, Anything in islam in permitted, Unless it is explicitly made haram. So according to this view, playing Carrom-board is not haram. Also, Anything becomes haram, if it takes away remembrance of Allah from you or stop you from doing ibligatory islamic duties.
And Allah knows the best
(Note:I am not a scholar, so you should better consult a scholar for proper fatwa, i just shared what know of)
Comment: +1. I believe there's a Hadith or a scholarly quote where it is said that anything that stops you from remembering your creator and/or causes you to delays/miss salaah is your idol.

Is playing carrom-board haram.?


What is an INTERLOCK in J1939?

Question: Hai I'm doing the project on J1939 Periodic Group Broadcast (PGB) protocol.
I had an document where it mentions the word "INTERLOCK".
I didnt get what is an INTERLOCK,First INTERLOCK,Second INTERLOCK actually does it means in the PGB protocol.
so can help me in understanding what INTERLOCK actually means in the J1939 protocol.
Thanks in Advance
Comment: see interlocks examples added to end of my answer
Answer: General answer. Appears to relate. MA not be what's wanted.
Interlocks are means of protection that do not allow some action to occur, or access to occur etc until or unless some condition is met.
Where there are a number of conditions which must be satisfied in time or mechanical sequence, each may require an interlock condition to b satisfied befoe the next stage can be initiated. Such sequential sets of interlock conditions can be called first interlock, second interlock etc indicating the order in which the conditions must be fulfilled.
"Interlock" does not seem to be a term which is used as a core part of J1939, but is used by some systems that implement J1939.
In some cases a subsytem may need to perform potentially dangerous task - eg a gear changing system may need to obtain throttle control to adjust engine speed during the gear changing sequence - but you would not usually want to allow the gear change system to have free control of the throttle. In such cases an interlock is initiated between gearchange and throttle systems for a limited period to provide the requisite functionality.
Here is a mechanical J1939 throttle control system. It provides hardware interlock on pin 3 with the rest of the system and will not function until interlock conditions have been met. In this case it is a manual control and the condition is the user knowing the "secret" rotation sequences requied to "trigger it".
J1939 electronic throttle with interlock

Also:
J1939 intro
and
J1939 overveiw - excellent references
J1939 implementations by manufacturer

General ; brake / shift interlock desirability mentioned here.
Ford electronic throttle module  -a number of mentions of interlock. It includes this table

FRC remote engine throttle - yellow lead mentioned in numerous diagrams is usually used for "pump engaged" inerlock.
LDSBBT see page 5 diagram.
Here there are a number of interconnected interlocks.
 Their logical rules are not described and the diagram would require a little thinking to fully decipher but it can be seen that there are interlocks controlled by gearbox-in-neutral, PTO engaged, Park brake on and ignition, with outputs to Throttle interlock and Okay to pump interlock.
Comment: Russell thanks for responding to my question but i hav all the documents which you have mentioned above and i didn't find any information about interlock in it.
Comment: @gOUSE - (1) The "throttle with interlock" document referred to above mentions hardware interlocking in a number of places. (2) My comments can be taken are independent of the links - and may or may not be useful

What is an INTERLOCK in J1939?


Does extreme value theorem hold when continuous is replaced with bounded?

Question: The extreme value theorem says that if the domain of a 'continuous' function is compact then both the max and min of the function lies in the domain set. My question is: can the 'continuity' be replaced by 'bounded' function keeping the domain compact and the theorem continue to hold? I haven't seen a proof, but if not, I'd be interested in seeing a counterexample.
Answer: I guess I found the counterexample myself. Consider the following function defined on $[0,1]$.
$$f(x) = \left \{ \begin{array}{ll} 2x & \mbox{ if } 0 \leq x < 0.5 \\
0.5 & \mbox{ if } 0.5 \leq x \leq 1 \end{array} \right .
$$
The sup of the function is $1$, but there is no point in the domain $[0,1]$ that 'attains' this point.
Answer: You cannot expect much help from compactness if you drop continuity. Take the function $x\mapsto\operatorname{sg}x-x$ on the compact interval $[-1,1]$ where 'sg' is the sign in $\{-1,0,1\}$, for a counterexample. Here the maximum and minimum of the function value do not exist, so the $\sup$ and $\inf$ of the function are not attained for any value in the domain.
In geneneral, for a function for which continuity is not demanded, topological properties of the domains and codomain have no influence on the kind of behaviour that the function can exhibit.
Comment: @Swaprava: Yes I saw that. Your rapidity of finding a counterexample makes me think: did you really try to solve this yourself before asking?
Comment: Thanks, I actually found similar counterexample (see below) before I could see this answer.
Comment: I was actually thinking aloud (read atype) :)
Answer: Consider the following bounded function defined on the closed interval $[0,1]$.
Let $f(x)=x$ for $0\leq x < 1$, and $f(1)=0$.
Then
$$
\sup_{x \in [0,1]} f(x)=1,
$$
but there is no element $x_0$ in the domain for which $f(x_0)=1$.
Answer: Let $\varphi: \mathbb R \to [0,1]$ be your favourite bijection. Then consider the function $f(x) = \arctan \varphi(x)$. You have $\sup_{x\in [0,1]} |f(x)| = \sup_{y \in \mathbb R} \left\lvert\arctan y\right\rvert = \tfrac\pi2$ yet the supremum is never attained.


Is there a way to add a Captcha to Ubercart?

Question: After some fraud attempts, I've been requested to add a Captcha to an Ubercart store in Drupal 7 and am surprised that in my searching I can't find any information on how to do this. Has anyone achieved this?
Answer: I am assuming you are talking about the add to cart form. Please share on what page or place you need captcha?
If you cannot find a module, then you need to do exactly what the captcha module does,

Write hook_fomr_FORM_ID_alter for the form for which you need to add the captcha.
Look for articles online explaining how to add captcha programmatically on a form in Drupal, ex: How do I add reCaptcha to a custom form?, https://www.drupal.org/node/743056.
Enable your custom module containing this code, and the captcha module.

You should have your captcha on ubercart's add to cart or any other form with a submit button.
Comment: Thanks -- working through with the person that requested it how much value a Captcha has on a multi-page checkout process but will accept this as the answer and may need to implement it pending outcome.


How to calculate the drag coefficient using terminal velocity?

Question: I was wondering if it were possible to calculate the drag coefficient by allowing an object to reach terminal velocity. Can you rearrange the terminal velocity formula to give the drag coefficient?
Answer: Yes you could. Since the force on an object from drag is given by
$$F_D = \frac{1}{2}\rho v^2 A C_D$$
where $C_D$ is the drag coefficient, then all you would need to know are your velocity ($v$), your fluid density $\rho$, your cross sectional area ($A$) and the force of gravity on the body, which would then be equivalent to $F_D$ since the body would have no net force on it. Thus, you could isolate for $C_D$, getting
$$C_D = 2mg/\rho v^2 A$$
Comment: Don't you mean $v^2$?
Comment: Same question here, Berhard. This should not be the accepted answer.
Comment: I have corrected the formula. Also, one could replace $F_g$ with $mg$, but I leave it up to the author.
Comment: Thanks for the edit, definitely meant $v^2$ and I'll change it to mg
Answer: Following on Spaderdabomb answer,
the drag force $F_D$ acts on the body and, as such, it balances with the other forces and the inertia of the body ($\sum\vec{F} = m\tfrac{d\vec{u}}{dt}$).
When you consider a situation where the body is at terminal velocity, this means its velocity is constant (at least in that direction) and its acceleration is null.
Consider the case of a parachute free falling at terminal velocity $\vec{u} = \{0,\,0,\,-w\}$, thus at constant $w$. As such $\tfrac{d\vec{u}}{dt} = 0$ and the force balance becomes $\sum\vec{F} = 0 \Leftrightarrow F_D^z - m g = 0$, noting that it is the drag that is sustaining the parachuter. From the perspective of the parachuter, the flow speed is $\vec{u}_\infty = \{0,\,0,\,w_\infty\}$ where $w_\infty = w$. As the drag is given by $F_D = C_D \tfrac{\rho}{2} w_\infty^2 A $, substituting in the force balance returns Spaderdabomb answer, $C_D = \tfrac{2 m g}{\rho w_\infty^2 A}$.


Unable to scroll wheel zoom with a Wacom Intuous Pro - Seems to think I'm Pressing Shift?

Question: I'm not sure if this is an issue with my tablet drivers, or with blender. I am using a Wacom Intuous Pro with touch is enabled so you can use two fingers to scroll wheel up and down.  I've been using this for ages in blender and it's been no bother.
Then, a few months back, for some reason unbeknownst to me, whenever I try to zoom in on Blender 2.79, the camera pans vertically. (As if I was holding down shift).  On blender 2.8, it just does nothing, but the tooltips at the bottom change to Pan View, Set 3d Cursor, and Move. (Again, as if I was holding down shift)
I've tried reinstalling Blender and my graphics tablet drivers. to no avail. There are no special program specific shortcuts set up in Wacom Tablet Properties.  And it works in every other application and game just fine.
Any thoughts for anything I can check? it just seems to think I'm pressing shift when I scroll wheel.
Also, as an additional thing, this is also true using the Touch Ring, on the side of the tablet. It just really thinks I'm pressing shift.
Wacom Tablet Driver versions are the latest: 6.3.38-2
Answer: To solve this simply change one of the touch ring functions, in Wacom Tablet Properties, to "zoom". This will stop the issue.


2015 Sentra tank does not fill up completely

Question: My 2015 Sentra SV stops taking gas before it's full.  I know for sure it's not a problem with the gauge as I ran the car almost empty and could only fill up a little over 7 gallons, whereas the tank can take a little over 13 gallons.  I tried to fill up slowly but could only add another 1/2 a gallon or so before gas started overflowing from the tank.  I would appreciate if someone could help.
Comment: How do you know you "ran the car almost empty"?  I would monitor my gas mileage on a full tank and see if it is consistent with burning almost 13 gallons when the fuel gauge *reports* that the tank is empty.
Comment: It is normal for it to stop 1/2 gallon before overflowing.  You want gas in the tank, not sitting in the fill hose and check valves.  There was a question previously that said overfilling your tank can damage your charcoal canister.  The gauge is likely set up so even if it appears you have nothing left at all, you still have a gallon or so left.  This is to help people from running out by making them think they have less than they actually do.  The only way to truly know is to drive it until you run out.
Answer: It sounds like you've picked up a pretty massive dent in your tank. Can you see underneath it well enough to determine if this is the case?
Comment: No there is no dent
Answer: A lot of vehicles today have a check valve that prevents them from leaking fuel out the fill port in case the vehicle rolls-over. Depending on the exact design of the check valve, some of them cause difficulty filling-up. Also, different fuel station pumps flow at different rates, not only because of design, but also because of the fuel level in the underground tanks.
If your filling problem is not new, this is likely the cause of it. Just fill slower, a lot slower. And take little 5-10 second breaks when the pump stops. Try a different fuel station, see if your Sentra likes their pumps better. I onced leased a 2010 Sentra and it always had this problem, solve it by filling much slower and avoiding some fuel stations.
If your filling problem is new, investigate as has been suggested in the comments:

Get your tank filled to the brim
Reset your trip odometer
See how many miles you get from a full tank
Look at what your fuel gauge is reading from time to time

It could be an electrical trouble (loose connection) with the fuel sensor, or the floater gets stuck somewhere. Most cars have an access hatch under the rear seat. Do not do this with a full tank, your car will stink of gas for a good long time, not to mention the fire risk.
Answer: There is a Technical Service Bulletin issued by Nissan that applies to many of their vehicles not being able to be filled.  Take it to the dealer and they'll hopefully replace your breather valve and hose.


How can I bypass stock tethering app?

Question: I have a rooted Coolpad catalyst with no cwm. I plan on creating a workaround for cwm but, that's another project. Anyway I have MetroPCS I've tried apps like barnacle, but I get WAN interface not found. It seems newer phones have a guard against root tethering methods, I thought about changing the settings app but can't risk it yet. I am running Android 5.1.1
Comment: Are you running the stock ROM (albeit rooted), or a true open-source ROM like CyanogenMod/LineageOS?
Answer: This app CWM Tether should help you.
Comment: I know I can bypass with USB I meant wireless
Answer: If you prefer doing this wirelessly, then you will to route your internet traffic via VPN.
You can obtain an Open VPN from playstore (e.g OpenVPN)
Basically whenever you wish to tether you will need to perform this code via terminal:
<code>iptables -t filter -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t filter -I FORWARD -j ACCEPT
iptables -t nat -I POSTROUTING -j MASQUERADE
ip rule add from 192.168.43.0/24 lookup 61
ip route add default dev tun0 scope link table 61
ip route add 192.168.43.0/24 dev wlan0 scope link table 61
ip route add broadcast 255.255.255.255 dev wlan0 scope link table 61
</code>
Benefits include:

Secured connections through the tunnel
Re-routing of traffic simulates a local connection and not tethering

However connections may be slow depending on server chosen.
Alternately you can get Foxfi Wifi tether  and is already configured to tether.
(Disclaimer: This is not a hacking proceedure, carefully read the Ts & Cs of your ISP if they allow tethering with 3rd party applications)

How can I bypass stock tethering app?


Path integral for complex scalar field

Question: I am taking a QFT course which focuses on the path integral formulation.
At a certain point, I was confused because we saw that, when integrating over complex Grassmann fields for fermions, we defined the complex conjugate as
$$(\theta\eta)^* = \eta^*\theta^*\tag{1}$$
and then said that we could treat $\theta$ and $\theta^*$ as independent variables, so we integrate over both variables. When I asked the lecturer about it, he said it was because complex conjugation is not uniquely defined for Grassmann variables, which means you can't really obtain $\theta^*$ from $\theta$, so you have to integrate over both.
However, let's consider we are calculating path integrals for a complex scalar field $\phi$. Would we integrate only over $\phi$ or both $\phi$ and $\phi^*$? Somehow I have seen both options in different references (for example, Peskin and Schroeder integrate only over $\phi$ in section 9.6). In this case $\phi$ and $\phi^*$ are dependent on each other, so you should only have one integration measure, right? Also, how would the integration results such as Gaussian integrals change when considering complex fields?
Answer: For simplicity, let's consider the standard complex integral (the path integral is just the limit of the product of many standard integrals).
A function defined on the complex plane $f(z)$ is the same as a function of two real variable $f(x,y)$, where $x+iy =z$. Therefore, integrating over the complex plane is the same as integrating over two real variables. Formally, we could write the measure $\text d^2 z= \text dx \text dy$ (with the $2$ exponent to remember that this is a $2$ dimensional integral).
However, it is often useful to take $(z,\bar z)$ as variables. At first, it might not be clear why this works. For differentiation, we can define $\partial = \frac12(\partial_x - i \partial_y)$ and $\bar{\partial} = \frac12(\partial_x + i \partial_y)$. Then you check that those differential operators satisfy the Leibniz rule as well as :
$$\partial z = \bar \partial \bar z = 1 \qquad \text{ and }\qquad \partial\bar z = \bar \partial z = 0$$
Therefore, everything happens as if $z$ and $\bar z$ where independent variables.
For integration, it goes the same way. We define $\text d z = \text d x + i \text dy$ and $\text d\bar z = \text dx - i \text dy$, and check that, up to normalization :
$$\text d^2 z = \text dx \text dy = \text d z \text d\bar z$$
Here again, we can act as if the two variables are independent.
Conclusion For a complex field (bosonic or fermionic), the path integral is an infinite product of $2$ dimensional complex integrals. Whether we write :
$$\mathcal D\phi = \prod_x \text d^2 \phi(x)$$
or
$$\mathcal D\phi\mathcal D\bar \phi = \prod_x \text d \phi(x) \prod_x \text d\bar \phi(x)$$
is purely a matter of conventions.
Comment: Thank you very much. So, if we discretized the integral $\int d^2z \ f(z,\overline{z})$, we would just sum over one set of variables $z$, right? So, for each point in the integral $z_i$, we would just substitute $f(z,\overline{z})\to f(z_{i},\overline{(z_{i})})$.
Comment: With the points $(z_i)$ filling the complex plane (or the relevant domain), yes.
Comment: Understood. I guess I was confused about the notation, then. Thank you!
Answer:
In the same way that a Grassmann-even field can be real or complex valued, a Grassmann-odd field can be real or complex valued.

Concerning P&S section 9.6, they consider a Grassmann-even complex field $\phi$. They write the path integral measure as ${\cal D}\phi$, while other authors would instead write the path integral measure as
${\cal D}\phi^{\ast}{\cal D}\phi$, but they really mean the same thing, cf. e.g. this Phys.SE post.

Concerning whether to treat the complex conjugate field as independent, see e.g. this related Phys.SE post.

Concerning OP's eq. (1) be aware that there exist different sign conventions in the literature for the complex conjugation of a product of Grassmann-odd variables.
Comment: Thank you very much for your answer and the links. I can see that the two fields are independent with respect to the derivative, which is useful for the classical equations of motion. The integral part is what I have a little more trouble visualizing, because it seems like we are summing over double the sets of fields in one case vs the other.

Path integral for complex scalar field


Infinite fringes in double-slit interference

Question: My professor told us that the fringes formed by interference will always be countable or finite. But I am just wondering, if, it is possible to have infinite fringes? Is there such a case? I am thinking that if the slit is placed too far from the screen, an infinite number of bright fringes will form. Or, in two-slit interference, suppose the screen is placed very far from the slits, will there be an infinite number of bright fringes formed on the screen? Your take on this?
Comment: Just a heads-up: countable does not mean finite, per se.
Comment: @Danu I guess he means finite or infinite countable.
Comment: I thought the two are interchangeable. Anyhow, thanks for telling that there is a distinction between the two. I'll keep that in mind. Thanks, @Danu.
Answer: Strictly according to Double Slit experiment calculations, yes infinite fringes are possible if (1) the slits are infinitesimal and placed infinitely apart, but actually, the fringes will be very close to each other so your eyes won't be able to differentiate and secondly each of the fringe will have almost $0$ intensity.So for obtaining infinite fringes you also need to have an infinite screen.
The above results come from the fact that for a fringe: $\frac{dsin\theta}{\lambda}=n$ Now for $n$ to be grow without bound, $d$ should be grow without bound.
Also replying on your suggestion that a screen placed infinitely far from the sources, you seem to assume that the distance between the fringes will get small, but this isn't the case as the distance between two consecutive fringes is $\frac{\lambda D}{d}$ so if you get $D \rightarrow \infty$ the fringes also get infinitely apart, thus even if you will have an infinite screen length, you will only be able to say a finite number of fringes on the screen as $\frac{\infty}{\infty}$ will be finite in this case as both are dependent on exponent $1$ of length hence are of same order, here the ratio of infinities is taken to denote number of fringes on the infinite screen.
Intuitively, you may think that the $sin\theta$ of the maxima gets smaller, as the screen is getting farther away but what also is happening is that $n$ and $\lambda$ are finite so to get to second maxima, you have to travel an infinite distance on the screen to change$\theta$ by an appreciable amount.
EDIT : It actually if you see carefully is a case of similar triangles. If the distance from the source gets infinity, then the fringe width gets infinity, if you draw out the case of two screens such that one is behind other, you'll see because for fixed $n,d,\lambda$ $\rightarrow$ $\sin\theta$ is constant.


Confused as to how to validate spring mvc form, what are my options?

Question: Latest spring mvc, using freemarker.
Hoping someone could tell me what my options are in terms of validating a form with spring mvc, and what the recommend way would be to do this.
I have a form that doesn't map directly to a model, it has input fields that when posted, will be used to initialize 2 model objects which I will then need to validate, and if they pass I will save them.
If they fail, I want to return back to the form, pre-fill the values with what the user entered and display the error messages.
I have read here and there about 2 methods, once of which I have done and understand how it works:
@RequestMapping(...., method = RequestMethod.POST)
public ModelAndView myMethod(@Valid MyModel, BindingResult bindingResult) {
  ModelAndView mav = new ModelAndView("some/view");
  mav.addObject("mymodel", myModel);

  if(bindingResult.hasErrors()) {
     return mav;
  }

}

Now this worked if my form mapped directly to the form, but in my situation I have:

form fields that don't map to any specific model, they have a few properties from 2 models.
before validation occurrs, I need to create the 2 models manually, set the values from the form, and manually set some properties also:
Call validate on both models (model1, model2), and append these error messages to the errors collection which I need to pass back to the same view page if things don't work.
when the form posts, I have to do some database calls, and based on those results may need to add additional messages to the errors collection.

Can someone tell me how to do this sort of validation?
Pseudo code below:
   Model1 model1 = new Model1();
   Model2 model2 = new Model2();

   // manually or somehow automatically set the posted form values to model1 and model2.

   // set some fields manually, not from posted form
   model1.setProperty10(GlobalSettings.getDefaultProperty10());
   model2.setProperty11(GlobalSettings.getDefaultProperty11());

   // db calls, if they fail, add to errors collection

   if(bindingResult.hasErrors()) {
     return mav;
   }

   // validation passed, save
   Model1Service.save(model1);
   Model2Service.save(model2);

   redirect to another view

Update
I have using the JSR 303 annotations on my models right now, and it would great if I can use those still.
Update II
Please read the bounty description below for a summary of what I am looking for.
Answer: Based on a similar experience, I'd propose the following and on the side I have a comment on the last step on the approach that you want to take. I use your numbered list of steps.

Step 1: Form Bean

There are two ways for this. The simple approach is to define a form bean (that I presume you've already done):
class MyModel {
  private Model1 model1;
  private Model2 model2;
  // standard Java bean stuff
}

A more precise way is to actually define MyModel such that I only borrows the fields that requires from Model1 and Model2 but I'm not sure if this fits your way.

Step 2: Data Binding

Spring does this for you if you have such form structure in your view:
<form:form modelAttribute="myModel">
  <form:input path="model1.somePropertyToBeSet" />
</form:form>

Step 3: Validation

Using Spring custom validations, you can define custom constraints:
@interface Model1Constraint {}
@interface Model2Constraint {}

class MyModel1 {

  @Model1Constraint
  private Model1 model1;

  @Model2Constraint
  private Model2 model2;

  // ...

}

Then register your custom validators for the custom constraints:
class Model1ConstraintValidator implements ConstraintValidator<Model1Constraint, Model1> {
// implementation of isValid and initalize
}

And the same for Model2Constraint. Using the custom validators, you can check what logic you need to ensure before MyModel is passed into request processing method. I also presume that you've used <mvc:annotation-driven /> to have Spring register the validators; otherwise, you should configure them.

Step 4: Custom model processing before request processing

Your original idea is to use some data binder for this job. In your description, you also mention that this data processing does not depend on the data coming from the form data.
Regarding design and modularity, I do not believe a data binder is a good place for such a purpose. Second to that, since there is no data dependency to the form, the major reason for you is to allow data binding error processing.
So, my suggestion is that let's say that now you're in public ModelAndView myMethod(@Valid MyModel model, BindingResult bindingResult). Presumably, you have access to other service beans here. So, you can have a method in some service bean that can refine or prepare (just names) the model that you've populated in this point. Based on exceptions or any other mechanism that suits you, you can use bindingResult to return the errors again.
As another suggestion, you may also take advantage of Spring interceptors if you'd like a more DI/IoC way to do it. But in this way, you should extract MyModel from ModelAndView in interception and proceed.
I hope this helps.
Answer: awesome explaination here, Please check Integrating Spring MVC 3.0 with JSR 303 (aka javax.validation.*)
Check this below example too JSR 303 Bean Validation Using Spring 3
Answer: This is an unusual problem, as it usually makes the most sense to validate the user input, as that is the data we can't control. With that being said, and since I'm sure you knew that already...
One option would be to use the JSR 303 validation api directly to validate your model objects after they've been populated from user input, database, etc..
Here's an example:
@RequestMapping(value=...)
public String myMethod(MyForm form, Model m) {

    ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
    Validator validator = factory.getValidator();

    Model1 model1 = createModel1FromUserInput(form);
    Model2 model2 = createModel2FromUserInput(form);

    Set<ConstraintViolation<?>> modelViolations = validator.validate(model1);
    modelViolations.add(validator.validate(model2));
    if(modelViolations.size() != 0) {
        m.addAttribute("violations", modelViolations);
        m.addAttribute("form", myForm); // add the form back to the model so it is populated
        return "formPage";
    }
    return "successPage";
}

You may prefer to bind to a Spring BindingResult or a collection of errors. I haven't tested the following code, and am not very comfortable working directly with BindingResult, so it will require tweaking:
BindingResult result = ... // not sure about the constructor
for(ConstraintViolation<?> violation : modelViolations) {
        result.addError(new ObjectError(violation.getPropertyPath().toString(),violation.getMessage()));
}

If you are just trying to spit out the errors on the JSP, then using a Set<ConstraintViolation> may work well enough for your needs:
<c:forEach items="${violations}" var="violation">
    ${violation.propertyPath}: ${violation.message}

</c:forEach>

If you are trying to use Spring's <form:errors> tag, you'll need to use the binding result.
HTH! Let me know if you have any more questions. Or if I completely missed the mark on this answer, I'll try to clarify.
Answer: Hibernate Validator 4.2 supports method level validation. You can refactor your code a bit to pass the two models in a method, and validate them.
http://java.dzone.com/articles/method-validation-spring-31
you can have something like this
public void persistUser(@NotNull @Valid Model1 model1, @NotNull @Valid Model2 model2) {

      //continue ...
}


how can i force a software run udp way?

Question: i want to know if i can force an specific program to use the udp protocol instead tcp on ubuntu 14.04?? There is any way to achieve this?? I need to jump a vlan and udp connections make the job.
Comment: which program ?
Comment: I m talking about a game, specifically Warcraft III 1.26, i need connecting me to a battlenet using udp instead tcp, because a private vlan.
Comment: ask the developers of warcraft 3 / battlenet  ;)
Answer: You cannot just force a program to use UDP instead of TCP, without rewriting parts of the program itself. These protocols are just too different to be interchangeable.

TCP is stream-oriented (the receiver sees everything as a continuous
stream in the exact order that the sender output it); UDP is
datagram-oriented (each datagram is sent in a separate packet, and
they can even get reordered).
TCP has flow control, so the sender (or the sender's OS) knows
exactly how fast it should send data without overflowing the link or
significantly affecting other connections. UDP doesn't do any of this
– a poorly-"forced" program might start sending gigabytes of data per
second over UDP, regardless of link speed
TCP has retransmission, so if a packet is dropped in the middle (e.g.
because the network is overloaded or has other problems) it will be
resent. If the protocol depends on a reliable transport and you force
it to go over UDP, the connection might die completely as soon as at
least a single packet gets lost. (And packets will get lost; see
points #1 and #2 above.)

Hope this helps!

how can i force a software run udp way?


What is the difference between Hot Reloading and Live Reloading in React Native?

Question: I'm a bit confused here. When I'm debugging a React Native Application, I usually enable both Hot Reloading and Live Reloading. I want to know what is the difference between them?
Comment: Question is outdated as of React Native 0.61. Hot Reload and Live Reload were merged into "Fast Refresh" - http://reactnative.dev/blog/2019/09/18/version-0.61
Answer: Live reloading reloads or refreshes the entire app when a file changes. For example, if you were four links deep into your navigation and saved a change, live reloading would restart the app and load the app back to the initial route.
Hot reloading only refreshes the files that were changed without losing the state of the app. For example, if you were four links deep into your navigation and saved a change to some styling, the state would not change, but the new styles would appear on the page without having to navigate back to the page you are on because you would still be on the same page.
Comment: Why would anyone prefer live reloading over hot reloading? Is there any benefit to live reloading?
Comment: This video from RN website might help also.
https://youtu.be/2uQzVi-KFuc
Comment: @Jan yes, generally hot reloading is preferable to live reloading. However, hot reloading is more complex to implement, and sometimes is not as reliable as live reloading.
Comment: Can both be done in Kotlin? If so, can you please direct me to a decent resource? Peace!
Comment: Do these only work when running in Expo, or also from an ejected app?
Answer: Both can be enabled using CMD+D / CMD+CTRL+Z / Shake Gesture menu. Both are using watchman to listen to the file changes.
Live reloading reloads the entire app.
The idea behind hot reloading is to keep the app running and to inject new versions of the files that you edited at runtime. This way, you don't lose any of your state which is especially useful if you are tweaking the UI. So it reloads only that page which you change more info here
Answer: Hot Reload:

Hot reload is used to refresh only the file in which code is change

Live Reload:

Live Reload is used to refresh the whole app it does not concern in
which file change comes.
Answer: The difference between the two is, Live Reloading is gonna reload your entire application. It's just gonna be like, okay, the file changed, reload the entire app. Hot Reloading is not gonna reload your entire application. It's just going to patch the code that was changed and keep the state in your app.
Answer: While developing a React-Native app you need to view your code changes
and for viewing code changes there are two options in React-Native.
NOTE: These two (hot reload and live relaod) features are merged in the 0.62 version of react-native as fast refresh and if you are using a version below then these two(hot reload and live reload) will be available.
You can explore this question for more information about fast refresh and hot reload
Difference between hot reload and fast refresh in react-native
1. Hot Reload
Hot reload just displays the code changes according to new code changes
without restarting the app from the start and its effects only on the
changed code or change will only apply to a specific component.
NOTE: Hot reload will not work sometimes if you are deep in your
navigation.
2. Live Reload
Sometimes we might need Live Reload to test our code like navigation so
Live reload is helpful in that case so it will reload the whole application on change in the code.
Answer: Hot reload just displays the code changes according to new code changes without restarting the app from start and it effects only on the changed code.
but its good when just styling the components when adding/changing JS code it creates problems.
For that Live reload or rr works good
Answer: Hot Reload: Hot reload is used to refresh only the file in which code is change
Live Reload: Live Reload is used to refresh the whole app.
Answer: In React Native,
Hot Reloading:

It provide feature you to update the code of your app without losing
the state of the app or manually refreshing the app. This is achieved
by injecting the new code into the running app, rather than replacing
the entire app.

How Hot Reloading Works?

When you make changes in your code, the React Native Packager will detect the changes and send the updated code to the running app. The app will then apply the changes to the appropriate components & allowing you to see the changes in the app without losing the current state.

Live Reloading:

The action refreshes the entire app whenever you make a change to the code. This involves replacing the entire app with the updated code, which means that the app will need to be restarted and the existing state will be reset.

How Live Reloading Works?

When you make changes in your code, the React Native Packager will replace the existing code with the updated code to the running app. The app will reset the current state of the app.

Hot Reloading is generally faster and more convenient, but Live Reloading can be useful in certain situations.
Comment: Sometimes live reloading is not working properly or if you need to reset the state of the app, In that case Hot reloading is more convenient.
Comment: Please note that hot reloading may not work in all cases, and you may need to use live reloading or manually refresh the app in certain situations.
Answer: Hot Reloading
What it does: Hot reloading allows you to inject new versions of the JavaScript code into the running React Native application without losing the state of the app.
How it works: It keeps the application running, and only updates the changed modules. The state of the app (such as the current screen, component states, etc.) is preserved during the update process.

Advantages
Faster updates: Since it only updates the changed modules, the update process is generally faster compared to a full reload.
Preserves state: The application state is retained, providing a seamless development experience.

Live Reloading
What it does: Live reloading refreshes the entire application when changes are detected, including the JavaScript code, assets, and styles. However, it does not preserve the state of the app.
How it works: It restarts the entire application, loading the new code and assets. This means that the application state is reset during the reload

Advantages:
Reflects all changes: Since it reloads the entire application, it ensures that all changes, including those outside the JavaScript code (e.g., assets, styles), are applied.
Simplicity: Live reloading is relatively straightforward and may be sufficient for certain development scenarios.

Choosing Between Them:
Hot Reloading: Preferred for its speed and ability to retain state. It's more convenient during development when you want to see the impact of your changes quickly without losing the current app state.

Live Reloading: Useful when you need to ensure that all changes, including those beyond the JavaScript code, are applied. However, it comes at the cost of losing the current app state with each reload.

Answer: Hot Reloading and Live Reloading are both features in React Native that aim to improve the development experience by allowing developers to see the immediate impact of code changes without having to manually refresh the entire application. However, there are some differences between the two:

Live Reloading:

How it works: When you make changes to your code and save the file, the entire app is recompiled, and the entire state of the app is reset. Then, the app is reloaded from the beginning.
Pros:

Simple and straightforward.
Useful for scenarios where the application state is not easily reproducible or when there are significant changes that require a full reset.

Cons:

Can be slower, especially for large applications, as it involves a full app reload.
May lose the current state of the application, making it less suitable for certain scenarios.

Hot Reloading:

How it works: Hot Reloading injects new versions of the files that you edited into the running app, allowing you to keep the app's current state while seeing the effects of your changes in real-time.
Pros:

Faster than Live Reloading because it only updates the changed modules instead of reloading the entire app.
Maintains the application state, making it more seamless for developers to see the impact of their changes without losing the current state of the app.

Cons:

It might not handle all types of changes perfectly, and some manual intervention may be required in certain cases.
Depending on the changes made, it might not always reflect the exact state of the application.

In summary, Live Reloading resets the entire app and reloads it from scratch, while Hot Reloading injects the changed code while preserving the app's state. Hot Reloading is generally preferred during development because it offers a faster and more seamless experience without losing the current application state. However, developers might switch between these modes based on the nature of the changes they are making.


How do I detect an entity with a certain name and replace it with a multi-block structure?

Question: I'm building a map in which the player needs to take a raft. The player is meant to place down a birch boat named "Raft" and when it's placed down, the boat is removed and replaced with an actual raft made of yellow wool. How would I go about doing this?
Comment: What have you tried so far? Or is this a "do my project for me" question?
Comment: Then you can write an answer, that way people in the future can find it if they have the same problem.
Comment: I have tried using scoreboards, but I can't figure out how to get the coordinates of the entity and place a block there. Also, please stop being so conclusive.
Comment: "conclusive"? How can that word describe a person? Anyway, saying "I tried using scoreboards" is like answering "a black one" to the question what computer you have. It's not wrong, but also not helpful. Scoreboards are a tool, not a plan or a solution on their own. What is your plan? What have you researched, tried, considered, …? I recommend reading the [tour] and a bit of the [help center], where it says that askers are supposed to put effort into their question, for example reducing their problem to exactly the thing they have problems with and what they tried so far.
Comment: I figured it out. I used testfor, execute, and clone commands. It's not flawless, but it works nicely. It took me several hours of research and work, before and after your message, but I'm happy with the result that I fully came up with, without asking someone to "do my project for me." Thanks for your help.
Answer: In order to make this task possible you will need two command blocks in a chain. The first one repeating always active and the second one chain always active and conditional.
The first command block could be "redstone active" or "always active" it will be set to repeating meaning it will happen 20 times every second or once every .05 seconds. Next put it on unconditional because there is no command block before it. Write the command /execute @e[type=boat,name=raft] ~ ~ ~ fill ~5 ~ ~5 ~-5 ~ ~-5 wool 4
The second command block could be both as well but must be powered when the top one is and vise versa. As for command block type it must be chain so it will activate after the repeating command block if powered. Last setting is the "conditional/unconditional" turn it to conditional so it will only work if the first one works. Set the command to /kill @e[type=boat,name=raft]

SUMMARY: First command block find "raft" and makes a 5 by 5 platform of yellow wool. Second command kills the "raft(s)" found.