Which factor should I consider to choose the best model, stationarity or lowest MSE?

Question: Recently, I did a project where I modelled a dataset of Gold price. I used ARIMA(1,1,1) and ARIMA(2,2,3) to model the data. The results that I get was ARIMA(1,1,1) was not stationary but the MSE value is low (118) and the ARIMA(2,2,3) is stationary but the MSE is high (170).
Comment: Thank you for posting on stats stack exchange. Unfortunately your question cannot be answered properly without any more knowledge of what you are doing. For example, even if you are trying to model the same underlying asset (gold) using different time frames would lead to different ARIMA structures, it's just the nature of the beast. Furthermore, why are you so worried that you got a different model this time? Is your question about modeling financial assets? Or you are asking what it means to have a higher MSE? Please take into considerations those questions, because anyone trying to answer w
Comment: Is your MSE in-sample, or on a holdout sample? What would a "best" model be for you (best forecasting performance? if so, by what error measure?)?
Answer: ARIMA(1,1,1) is a nonstationary process as it contains a (single) unit root; the order of integration (the middle number in the parentheses) tells you that. ARIMA(2,2,3) also is a nonstationary process as it contains two unit roots. However, in neither case is this a fundamental problem; there are well-known estimators of the model's parameters that have favorable properties (consistency, asymptotic normality) that are implemented in numerous statistical packages. What should concern you, on the other hand, is the stationarity of the error term. You should examine the models' residuals (proxies for the errors) and see that they are i.i.d. as a precondition for trusting your models.
If you have chosen to judge your models by MSE, you must be facing square loss. If that is the case, lower out-of-sample MSE is better, and a model delivering that can be preferred.* If you are not facing square loss (but e.g. absolute loss), consider using an appropriate loss function / error metric (e.g. mean absolute error) for judging your models' out-of-sample performance and for comparisons across models.
*In-sample MSE can be a poor measure of prediction quality, especially for models with many parameters. It is also a poor measure for model comparison, as it favours models with many parameters regardless of their actual out-of-sample forecasting ability. Information criteria can remedy that; comparing models' AICs or BICs therefore can make more sense than comparing in-sample MSEs.


How to perform a parallel hash over a large file without changing the sequential hash result?

Question: I want to use parallel hash for a large file. I want final result equal to single hash from this file. What techniques would be best suitable to solving this problem?
Comment: @md That depends on how you define the "simple hash". If the simple hash is basic SHA-2/3 you are out of luck. But unless you need compatibility with an existing system, you can simply choose a parallelizable hash construction, like those I outline in my answer.
Comment: Define _"single hash"_, and ranking of criteria for "_Best"_. Would you be satisfied with a _simple_ variant of SHA-512, based on the same round function, that uses marginally more code, memory, and CPU time than SHA-512 for a sequential implementation, but allows parallel hashing?
Comment: @Msd I've changed the question somewhat, hopefully keeping it mostly in line to your question. Reason: asking for "the best" is considered opinionated and that's a valid reason to put the question on hold. Still, please answer fgrieu to indicate if you would be satisfied with such an answer.
Comment: @fgrieu Now you've gotten me curious if you've got an answer that is different from a M.T. ...
Comment: @Maarten Bodewes: I have no answer to the reworded question, and I doubt there is one for stringent-enough definition of _sequential/single hash_. I was considering the "blocked" construction in this [question](http://crypto.stackexchange.com/q/360), which is even more basic and easily re-turned sequential than the "interleaved" method in [CodesInChaos's answer](http://crypto.stackexchange.com/a/44261).
Comment: Thank you all,
Result of parallel hash technique must be equal to hash of entire file(simple hash from file). Calculating speed must be improved in this solution. Is it possible?
Answer: If you want to produce a hash compatible with an existing sequential hash, like SHA-2, you're out of luck. But when you choose a parallel mode, you can always compute the same output using a single thread.
The two most important parallel constructions are:

Interleaved
You initialize a fixed number of sequential hashes. Then you feed them one block in turn. At the end of the file you take the outputs of the individual hashes and hash it down into a single hash.
The biggest downside of this approach is that you need to choose the maximal parallelism at design time and changing it breaks compatibility. It still needs to process the file start to finish, it can only take advantage of multi-core CPUs but can't parallelize IO by hashing different parts of the file at the same time.
A (deep) Merkle-Tree.
For example the Tiger-Tree-Hash splits the file into 1 KiB and computes an unlimited depth binary hash tree over it. (Don't forget tagging leaves and inner nodes differently, or an equivalent mechanism to avoid ambiguities)
This has slightly higher CPU (a few percent) and memory (a few KB) overhead. It can only parallelize hashing files larger than the leaf size.
In exchange you can hash pieces independently in any order and the maximal parallelism grows with the file size.

Personally I prefer the tree approach due to its flexibility.

If you can use a key, you can use a PRF/MAC instead of a collision resistant hash. For example GHash (the MAC part of GCM) is very flexible in how it allows you to partition and parallelize the computation. It's also much cheaper to compute than collision resistant hashes.


Highlight current row when dragging over a silverlight datagrid

Question: Using Silverlight 4, I have a DataGrid.  I am grabbing a file from Windows Explorer and dragging it over the grid (I set AllowDrop=true on my DataGrid).  When I drag over the grid I would like to highlight the row that the mouse is currently over (I want to point out to the user which row the file will be dropped if they release the mouse button at that time).
How can I do this?
Answer: this can be done by attaching Mouseover events .. Can't it?


Ubuntu 12.04 - apt-get install ia32-libs unmet dependencies

Question: Trying to install ia32-libs. I run sudo apt-get install ia32-libs. The output is as follows:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ia32-libs : Depends: lib32v4l-0 (>= 0.5.0)
E: Unable to correct problems, you have held broken packages.

I have tried sudo apt-get install -f, sudo apt-get update, and sudo apt-get upgrade. I tried doing sudo apt-get install lib32v41-0, but that doesn't work either because the package cannot be found.
sudo apt-get install lib32v41-0
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package lib32v41-0

Any suggestions on how to get ia32-libs installed?
Answer: ia32-libs was really just a hack to get 32 bit libs onto 64 bits as a hold over waiting for multi-arch, which we now have, making ia32-libs obsolete.  You can now install i386 packages directly into and amd64 install, once you enable it.
I'm assuming that now you are on amd64.  To verify, run dpkg --print-architecture and expect it to return amd64.  Then you can check if i386 is listed as a foreign architecture with dpkg --print-foreign-architectures.  If it is not, you can enable i386 with dpkg --add-architecture i386.  Then after apt-get update, you can install a i386 version of a library by appending :i386 to the package name, for example, to install the i386 build of ncurses, you'd run apt-get install libncurses5:i386.
Comment: The program im trying to use isn't working properly, and they specifically said to try to install ia32-libs to get it working. But thats not possible due to the reason above. Your information is a useful alternative, but for the purpose of troubleshooting, i'd like to get ia32-libs working.
Comment: give us more information about why it isn't working and we can figure out which packages you need to install.  ia32-libs isn't a good option for your version of ubuntu.


Regarding probability and the birthday paradox

Question: I have a question which states that
"In a group of 23 people what is the probability that there are two people with the same birthday? Assume there are 365 days in a year. Ignore leap years and such complications. Assume there is an equal probability of a person being born on each day of the year.". I solved it using the complement. I first computed the number of ways in which we can assign the birthdays to 23 people out of 365 days (without replacement). That gave 365 * (365-1).. (365-k+1). Then I divided this by 365^k. Then I subtracted the result from 1. But, the probability which I have now got may also contain 3 people having the same birthday or 4 people having the same birthday, etc. I want to know the probability of exactly two people having the same birthday. In short, what I have computer is, " what's the probability that AT LEAST TWO PEOPLE HAVE SAME BIRTHDAY" and what I'm looking for is "WHAT IS THE PROBABILITY OF EXACTLY TWO PEOPLE HAVING THE SAME BIRTHDAY".How do I compute that probability?
Comment: This is far more complicated.  To clarify : You mean the event that there are two people having the same birthday and all the other people have another birthday and moreover distinct birthdays, so that we have just one "collision" ?
Comment: It's a reasonable question to ask either way, but it's possible that the question you want to answer didn't expect you to be that specific, and just wants the probability you've found so far.
Comment: But if we want to calculate the probability that I'm looking for, how can we do that?
Answer: The denominator is still going to be $365^k$.
In the numerator, we have:

$365$ ways to choose the repeated birthday;
$\binom{364}{k-2}$ ways to choose the birthdays that are not repeated;
$\frac12 k!$ ways to permute the resulting days, dividing by $2$ because the two repeated birthdays can be swapped.

So we get a probability of $$\frac{365  \cdot\binom{364}{k-2} \cdot \frac12 k!}{365^k} = \frac{k! \binom{364}{k-2}}{2 \cdot 365^{k-1}}.$$
Set $k=23$ to get the probability you want.

Another option for the numerator, which will get an equivalent answer. First, there are $\binom k2$ ways to choose which two people have the same birthday. Then, we can take the same product $365 \cdot 364 \cdot 363 \cdots$ to fill in the birthdays, but there is one difference. Once we pick the birthdays of one person in the repeated pair, we get the other one for free. So instead of having the $k$-factor product $365 \cdot 364 \cdots (365-k+1)$, we get the $(k-1)$-factor product $365 \cdot 364 \cdots (365-k+2)$.
The result is
$$
   \frac{\binom k2 \cdot 365 \cdot 364 \cdots (365-k+2)}{365^k}.
$$
Comment: What do you mean by "365 ways to choose the repeated birthday"?
Comment: We're looking for a situation in which one birthday occurs twice, and $k-2$ other birthdays only occur once, right? There are $365$ ways to choose the birthday that occurs twice.
Comment: Honestly, this is too complicated to understand. But thanks for the help:)
Comment: I've added another way to think about the answer; maybe that one will make more sense?
Comment: Yes, it is making more sense now. Thanks a lot!!
Answer: If by exaclty you mean any two peaople having same birthday and all the rest having different birthday, then we can do it for ingeneral having $i$ peaople out of $k$ with same birthday as follows:
For each fixed day of 365 days there are $\binom{k}{i}$ ways of chosing $i$ people having that day as birthday, by wich there are $364(364-1)(364-2)\ldots(364-k+i+1)$ ways of the rest $k-i$ people having different birthday, so the probability of exactly $i$ having the same birthday is
$$P(i)=\frac{365\binom{k}{i}364(364-1)(364-2)\ldots(364-k+i+1)}{365^k}$$
Comment: I understood. The explanation was too clear. Thanks a lot!!:)


How can I recalculate field values of a rendered node?

Question: For example on a recipe node, exposing a "yield" field on a rendered node to recalculate ingredient quantity values
Answer: I dont think there is any module that you can use, you can try hook_node_view_alter hook to change the rendered.

If the module wishes to act on the rendered HTML of the node rather
  than the structured content array, it may use this hook to add a
  post_render callback. Alternatively, it could also implement hook_preprocess_node(). See drupal_render() and theme() documentation
  respectively for details.

Check hook_entity_view_alter too
If you want to change in the node create form, there is Conditional Fields Module.

Define dependencies between fields based on their states and values.
  Conditional Fields for Drupal 7 is an user interface to the new States
  API, plus the ability to modify fields appearance and behavior on
  certain conditions when viewing content.

Installation and Usage
Comment: You're wrong, there is a module for just that. Posted in my answer.
Comment: @Mołot Is the availability of module means i am wrong ?
Comment: Yes, in the "I dont think there is any module" part on the beginning of your answer. The rest is valid.
Answer: Computed Field module can be configured to work just the way you need:

You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views.
Comment: would this allow for end user input?
Comment: If you will not store it in database, then it might. Tricky part would be to make user able to input. Maybe Webform or Quick Forms are what you are looking for. Ask another question with explanation about user input you want, and who is "end user" in your use case.


Could Python be compiled to run on the V8 Engine?

Question: Presumably Javascript is compiled to some kind of byte-code to run on the V8 Engine? Is Python a similar enough language that we can imagine Python being compiled to the same byte-code and run on the V8?
Any projects trying to do this?
Comment: Is this a question about optimizing python, or is this a question about compiling Python to a form that can be directly executed by the Javascript interpreter on current browsers?
Answer: As far as I know, there are no projects that specifically target the V8 virtual machine. However, Pypy and the erstwhile Unladen Swallow (now merged into the py3k-jit branch of the main CPython tree), both attempt to just-in-time compile Python into native code, similar to what V8 does with Javascript.
As @something says, pyjamas allows you to write Python code and translate it into Javascript, much like GWT does with Java. Any code translated thus would have the same benefits to running under V8 as any other Javascript code.
Answer: There are already three projects that provide a Python to Javascript compiler. The resulting Javascript can then be run on any engine including V8. Look for Pyjamas, Skulpt and Py2JS.
This is not the same as compiling Python to V8 bytecodes, but the end result is much the same.
Answer: V8 doesn't actually have a general purpose bytecode.  There's a regexp byte code, but support is not usually compiled in.  There's a deserialization byte code and a relocation information byte code, but both are implemtation details and you can't use them for anything.
So what you are looking for is something that compiles to JS source code.
Answer: For ways to run python inside browsers, see the python wiki page WebBrowserProgramming.
Answer: Are you maybe looking for something like "Pyjamas"?
http://pyjs.org/
Answer: Have a look at http://repl.it/ - it's an example of a pretty much complete Python interpreter compiled to JavaScript. This was achieved thanks to Emscripten - a compiler of LLVM bytecode to Javascript.
Answer: Python is already compiled to bytecode and executed.  This is what the .pyc files are in CPython. Jython likewise compiles to Java bytecode (dynamically), and so does IronPython for .NET
Comment: This has nothing to do with the V8 Javascript engine.
Comment: The question is about targeting V8, specifically, not about Python byte codes in general.
Comment: Way I interpreted the question, it was about compiling python to bytecode, of which V8 was given as an example.


How do I browse diff of a file in TortoiseSVN?

Question: I am currently using TortoiseSVN as my source control in Windows. How do I view the diff of a single file as I move through the different revisions quickly? Or is there a better tool?
Answer: To see the revisions of the file you can right click the file and choose

TortoiseSVN -> Show Log

Then, from there you can select multiple items and choose Compare Revisions
Answer: I think what you might really like is an open source tool called svn-time-lapse-view.
It's a Java executable jar file that lets you load all the revisions for a file and then use a slider to scroll/cycle through all of the version changes with the diff shown below the slider.
Much faster than opening the log and selecting two files over and over again.
Answer: I think you might want to have a look at the Blame tool.  It will annotate each line of source with the revision number in which it was last modified.
Answer: Right-click on the file > TurtoiseSVN > Diff or Diff with previous version. You can also use Show Log, then right-click the file and use any of the "Compare" options.
I personally use WinMerge for merging and showing differences.


How to create realistic alien evolution in a swampy planet? (Like dagobah from Star Wars)

Question: Essentially, I'm curious to know what would be the most likely (semi-complex, multicellular) animal lifeforms to develop on planets with gravity similar to Mars and Earth.
Comment: I have voted to close for now. The question can definitely be a good one, but currently can be answered with a list. Anything not human and still complex is valid, making it even a rather long list.
Comment: Your title question is not a question and your main body does not have a question mark.
Answer: Honestly, roaches, kind of like District 9. They would be intelligent enough and have many usable limbs. This question is kind of vague so almost anything can work here, even a blob-person.
Answer: Crabs

Crabs have evolved on Earth several times. A process called carcinisation.

I guess that means if life evolved on Mars it . . . MIGHT be crabs.
Comment: @LittlePickle. It is more specific than Convergent Evolution.
Comment: It took a while, but I got it. ;)
Answer: I would go with the ocotopi!
They are highly intelligent, by some measures of problem solving they are smarter than six-year-old humans.
And completely alien to humans. Five lobed brains, 8 arms that each have mini-brains of their own, they reproduce differently, master manipulators with there arms and individually controlled suckers, and on and on.
Octopi would be an excellent starting point for aliens.
(In the current series "Resident Alien", the alien is descended from octopi.)
Answer: You should exlain what you want in more detail.  YOur question as it is worded now, 2:26 pm EST on May 7, 2022, is vague enough to have several possible meanings.
Do you plaln to create a planet wth only one species of complex plant or animal life, or a planet with thousands or millions of species of complex plant and animal equvalent lifeforms?
Do you want to create a complex alien animal that is many times as intelligent as the least intelligent multicelled animals but only a fraction as intelligent as humans, or do you want to create a complex alien species of intelligent beings?
I note that if you want to create a realkistic and plausible species of intelligent but non humanoid aliens, the logical thing to do would be to make them similar to species on Earth which are considered most likely to have human or near human intelligence levels.


How to determine torque when using quick release?

Question: I want to be able to install my front wheel on my Lauf Carbonara fork without using and carrying a torque wrench, e.g. during a longer tour.
Lauf says that the preinstalled axle can be replaced eg a RockShox Maxle. I am just very much clueless about how I would know when the required torque is reached when using a lever-type axle?
Answer: I'm presuming this is a lever-style axle, similar to a classic QR skewer?
The guideline is usually to have the cam begin to fully engage when the lever is sticking out 90° (lever parallel to shaft). What I mean by "begin to fully engage" is there is often a brief "mushy" section of the lever's action as all the parts come together and tension begins to increase. You want this 90° thing to occur at the start of pure tensioning, after this initial phase.
You should see a red mark on your hand when you've tightened it correctly. If you need a tool to help open or close, that is too tight.

If I'm mistaken and this is actually a bolt-on axle, the simplest way to avoid needing a torque wrench is to practice torquing it and then loosening it a few times. You'll soon gain a feel for how tight it needs to be. Furthermore, you could also mark the relative positions of the axle and dropouts with some paint or something. When the paint marks align, the axle is correctly tightened.
Comment: The Carbonara comes with a bolt-on axle. I'll just try aka practice at home how to have a lever style axis tightened to the Nm required.


Sandbox Source Tracking does not activate

Question: I have enabled source tracking in Developer and Developer Pro sandboxes in the production org, but source tracking commands still throw an error even after a sandbox refresh.
Some details: we have a master sandbox(developer) with some test data already created and we refresh/create our sandboxes from it. After I activated the Source Tracking in Dev and Dev Pro Sandboxes, I refreshed my sandbox from the master sandbox(both are developer sandboxes), re-authorized the org in my VSC and also restarted VSC, but I am still getting the error when I try to reset the tracking:
<code>PS C:\Users\Novarg\Documents\VSCode\salesforce-sfdx> sfdx force:source:tracking:reset
WARNING: apiVersion configuration overridden at "56.0"
WARNING: This operation will modify all your local source tracking files. The operation can have unintended consequences on all the force:source commands. Are you sure you want to proceed (y/n)?: y
ERROR running force:source:tracking:reset:  This command can only be used on orgs that have source tracking enabled, such as sandboxes and scratch orgs.
</code>
My guess is that we did not have source tracking activated in the master sandbox, so a refreshed sandbox from it also did not have it enabled. I also checked the documentation, but it does not say anything about refreshing sandboxes from an existing sandbox. The only requirement is to create/refresh a sandbox after activating this feature which I have done.
Is it documented somewhere that we need to refresh or create a sandbox from production or does it just take a while to register and I should try refreshing again tomorrow?
Answer: Yup. The documentation is misleading or incomplete. Refreshing or cloning a sandbox from an existing sandbox where the source control is not enabled doesn't enable source tracking on newly created sandbox


differential to single ended output problem

Question: I have a differential input of 2-V and it apply to TLV-2221 op-amp with unity gain of one, but the output shows the zero voltage waveform,can anyone explain why it happens? here i am attaching the screenshots of my simulation.
Comment: Very-much related to this earlier question: https://electronics.stackexchange.com/questions/519889/op-amp-output-problem
Comment: Get rid of the yellow waveform - it's cluttering the view.
Comment: yes,this question was related to that question ,with different resistor values we observe the output waveform differently,but all four resistors are with same value in tlv2221(unity gain),then theoritically we got the same output as output of amc1301 ,but in simulation it doesn't show like,what is the mistake here
Comment: What is the common mode voltage of the red signal?
Answer: Let's start at the beginning. The gain of the AMC1301 is 8.2x. The input signal range is + - 250 mV. Thus, a + -2 V signal is expected at the output.

If we needed the full range, the 3.3 V supply voltage would be little for the 4 Vpp signal. Then we need to use a supply voltage of at least 5V. However, a supply voltage of 3.3 V is sufficient to solve the specific task. The next problem is that the input voltage of the TLV2221 can be between 0 and 2V at a supply voltage of 3.3V.
The Vp signal exceeds this value.

So we definitely have to choose a different amplifier. Select the same one you used for the older similar task.

The input DC offset voltage determines our operating points throughout. The operational amplifier must be set so that half of the supply voltage is at output. (For maximum dynamics.) The input already has a 1 V offset voltage. To do this, approx. 0.5 V must be added plus (VREF). We will do this by building a divider from two resistors with a voltage of 550 mV and the internal resistance 10k Ohm:

Thus we got to the point where we created an asymmetric from the original symmetric signal:


AS3 - How to assign names or tags to loader?

Question: I have a list of images that i've loaded with the Loader class, but I'm having a tough time assigning them unique names.
I need unique names because I want to remove certain images after a while.
Is there a way to assign loaders a name or some unique tag so i can remove them later? thanks.
Here's part of my code
for (var i = startnum; i < endnum; i++){
    var thumb = panels[i].@THUMB;
    var thumb_loader = new Loader();
    thumb_loader.load(new URLRequest(thumb));
    thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);

    thumb_loader.name = i;
    thumb_loader.x = (thumb_width + 20)*i;
}

I tried to use getChildByName in another function..
var myLoader:Loader = getChildByName( "1" ) as Loader;
myLoader.unload();

But it's giving me
Error #1009: Cannot access a property or method of a null object reference.
I tried to put thumb_loader as global variable, and do this
var myLoader:Loader = thumb_loader.getChildByName( "1" ) as Loader;

But it's still not working.
Thanks.
Answer: All display objects in ActionScript 3 have a name property. Whenever you create a Loader object you can assign a name to it like so:
var myLoader:Loader = new Loader();
myLoader.name = "myUniqueName";
myLoader.load( .... );
addChild( myLoader );

If you'd like to refer to the loader by the name you gave it, use the getChildByName() method.
var myLoader:Loader = getChildByName( "myUniqueName" ) as Loader;
myLoader.unload();

Please be mindful that getChildByName() will only work after you've added the Loader(s) to the display list using addChild(). Otherwise, you'll have to create something to store the references to the Loader objects in, such as an Array and refer to the loaders via that Array. For example, outside your loop you could create an Array named loadersArr. In your loop you would do:
loadersArr["uniqueName"] = thumb_loader;

Then you can refer to your loaders with your unique name through the loadersArr Array.
var loaderToUnload:Loader = loadersArr["uniqueName"];
loaderToUnload.unload();

Without seeing more of your code, its difficult to understand the scope in which this code resides and where any other code that may try to reference these Loaders resides.
Comment: but it's giving me this error
Error #1009: Cannot access a property or method of a null object reference.
Comment: It is difficult to know why you are getting this error without seeing your code.
Answer: Not sure I 100% understand your problem, but why not put them in an object map rather than a list and generate unique names for them if you don't have them...
var img:Image;
var img_map:Object = new Object();
var last_added:int = 0;
for each (img in yourListOfImages)
{
    img_map["img_"+last_added] = img;
    last_added++;
}

Depending on your environment (Flex or Flash) you can use a UID generator instead of my simplistic unique names above.
Answer: package
{
    import flash.display.Loader;

    public dynamic class DynamicLoader extends Loader
    {
        public function DynamicLoader()
        {
            super();
        }
    }
}

I believe the Loader class is a sealed class so you would want to create this class and use it instead of the normal Loader class to give it any attribute you want. I also believe that without using this DynamicLoader instead of the normal Loader, the Loader class does have the name property available to it.


Star Smog Checks

Question: I have an MR2 Spyder with 80,000 miles on it runs great but the check engine light is on and the smog technician stated that even if I reset the check engine light it would still not pass smog no matter what the reason for the check engine light being on is that true?
Answer: What the technician told you is exactly right.
OBD2 cars have their emissions measured (at least in most states) by the readings of the computer in the car (OBD1 cars still must use tail pipe readings). The OBD2 system does what's called a drive cycle. Every manufacturer has their own drive cycle. The drive cycle eliminates (IIRC) eight different things it checks for having to do with emissions.  When you reset the computer (erase all of the codes - for whatever reason) and reset the CEL light (goes dark), you still have to put the car through its drive cycle. If you don't, it's still in limbo and will not pass the test. If you have an emissions related issue, resetting the computer and going through the drive cycle will only cause the issue to reappear as a CEL.
The tech was also correct in that if the CEL is on for any reason, it's an automatic failure. Even if it's an innocuous code (nothing to do with emissions), you still fail.
Answer: Most smog tests are done by measuring the exhaust emissions using a sensor in the tailpipe, so resetting the light will make no difference - you need to sort out the emissions to make sure they are below the limit for your jurisdiction. You should get the codes read to find out why the CEL was on, and fix the problem that caused it.
If you edit your question to state which country (and state, if applicable) you are in, some of our members may be able to help more.

Star Smog Checks


I'm wondering about CUPS security. What can I do?

Question: I run Debian Wheezy on a old Acer Aspire One ZG5 model netbook as a server. I have a printer shared to all my other systems and I'm worried about security. On the server I have IPtables set up to block everything that hasn't been initiated by the server itself and I opened ssh, cups (631), AVAHI (assumed 5353 for airplay printing). I just want to make sure no one but my trusted systems can print, that no one but me can get in a change CUPS settings via web or otherwise, and that no one can use a obscure CUPS hole to mess with my server. I have one iPhone, one android tablet, and two Debian Wheezy Laptops I want to share my printer with. I'm unsure how to go about securing CUPS or what even is the best security to use with CUPS.
Answer: As long as your private network is not accessible from the internet, you will have no problem.


Down vote, edit or add comment. What should one do?

Question: A couple of times, some questions have a lot of grammatical errors due to the fact that the people asking them are not good English speakers. Other times, the questions are not asked well because the person asking could be a newbie in the area in which he/she is asking the question. At times people don't see reasons why questions might not be asked properly and simply down vote it. Is it better to down vote or to comment (telling the fellow things that can help him state his problems better) or to edit the question
Comment: I will have to agree with you about the issue with poor questions. It is sometimes troublesome trying to figure what the persons intention are. Also, people need to take the time to formulate a "good" question. What is your issue? What are your possible solutions?
Answer:
some questions have a lot of grammatical errors due to the fact that
  the people asking them are not good English speakers.

If you notice that, but the point of the question is clear, then correct the grammar/spelling.  And even if it's not entirely clear but you sort of get the idea where the question is going, ask for clarification. Not everybody is fluent in English, so when I see that some effort has been put into the question, I usually try to correct and clarify it.

Other times, the questions are not asked well because the person
  asking could be a newbie in the area in which he/she is asking the
  question

If the question is a genuine one and not a duplicate or something that can be answered with a Google search or a RTFM, then help and clarify it. Or coach the OP towards a proper question.
I would generally reserve my down vote for those questions which show no effort on behalf of the OP. And even then I personally often prefer to vote for closure (if there is no way to save the question) rather than down vote. But then again it is not up to me (or anyone else) to say when you should or should not down vote. You're free to do with your vote whatever you want.
Comment: I've often found that _trying_ to edit poor grammar makes it much clearer whether there is in fact a real question in there. Sometimes there isn't and you just have to throw up your hands and cast that NARQ vote.
Comment: @JoshCaswell Exactly, that is usually my approach as well. There are many questions where halfway through an edit I have given up because there is simply no saving it.
Answer: On Stack Overflow (but not the newer sites) we have many more questions than we need – but we still benefit from more quality answers.
As badly written, unclear questions make it less likely someone will stay about to answer questions, I think we should not be too concerned if our actions leads to less low quality questions being asked!
As a thought experiment, would SO be better if the 10% of the users that ask the least clear questions were to never use the site again?
Answer: I feel that down voting due to the grammatical quality of the question is counterproductive and disheartening, you said yourself they may not be good English speakers. In this case i would merely edit the question so that it makes sense to others.
If questions asked are not asked well due to the asker being new to the subject i would also reserve my down vote, as this is a community site for those of all abilities i would hope the majority of users would try to point the asker in the right direction.
Comment: I feel what you are saying. However, we have to be careful, IMHO, not to encourage new users to develop bad asking habits. Also, I would disagree that SO is for users of *all* abilities; It is for "enthusiasts and professionals". That suggests at least a basic understanding of programming. A question like, "what's a variable?" should be slain with enthusiasm, and the user directed elsewhere. IMHO. +1 anyway :)
Comment: Thanks for the +1, i agree with what you are saying but i feel that users should be given the chance to gain that basic knowledge if that is what they seek. If a user asks the question, "what's a variable?" i would be more inclined to direct them to a piece of relevant literature as opposed to down voting..
Comment: I do agree that a down vote in that *specific* case would not be helpful. However, I would be voting to close and then delete, instead.


scala reflection field class

Question: I'm trying to get the type of an attribute that refers to a custom class, I just get that it's of type Object
My code:
class Edge[N <% Node](var from : N, var to : N) {

  def toXml(c: Class): xml.Elem = {
    <edge>{
      for(field: Field <- classOf[this.type].getDeclaredFields)
        yield <field name={field.name} tpe={field.tpe.toString()}>{ this.getClass().getMethods.find(_.getName() == field.name).get.invoke(this) }</field>
    }</edge>
  }

So the problem here is that I need to switch between the java Field and scala Field: apparently there is no such thing as this.getClass in scala? So I need to go through Java to get the class?
However this seems to only result in Objects as types?
Answer: EDIT: The revised question is: Should scala.reflect.Field or java.lang.reflect.Field be used?
Answer: Always[*] use java.lang.reflect.Field, and in general java reflection for two reasons:

That is what is returned by xxx.getClass().getDeclaredFields()
The following comment is next to the definition of scala.reflect.Field

.
/** This type is required by the compiler and should not be used in client code. */
case class Field(override val fullname: String, tpe: Type) extends GlobalSymbol(fullname)

[*] At least for now. reflection is coming soon to Scala.
--
Original answer:
It would help if you posted the class code as well, but it seems that the field is declared as Object. getType returns the declaration class of the field.
From Field#getType():

Returns a Class object that identifies the declared type for the field
  represented by this Field object.

class Foo {
  var bar: String = "string"
  var bar2: java.lang.Object = "string"
}

for (field <- new Foo().getClass.getDeclaredFields())  {
   println("field=" + field.getName() + " " + field.getType.toString())
}

gives
field=bar class java.lang.String
field=bar2 class java.lang.Object

If you want the type of the instance, then you will have to do a .getClass() on the instance in the normal way.

scala reflection field class


What is a vCard and how to read it?

Question: What is a vCard  and how do I read it? It popped up in a message from a friend and I don't know what it is. Please explain.
Answer: A vCard is contact information in a standardized form, accepted by most applications that deal in people or contact information. It is transportable between systems of differing operating systems, because of its defined form, generally: Name, Address, Phone Number, Notes, etc.
In Android, the standard application to read this is called either People or Contacts. If you open the application and find the activity menu about it, one of the allowed processes will probably accept the data through "Import".
If you received it attached to a message, possibly even the messaging app will allow the import to the correct place in your system. See if its activity menu allows some processing of the attachment, similarly "Import".

What is a vCard and how to read it?


Use of loopback Interface in iBGP

Question: As I understand that the loopback interface(127.0.0.1) is used to route packets back to the source. How is it then used to talk to iBGP neighbors? I understand that the goal is to ensure that the interface doesn't go down, so using an emulated/software interface ensures that, but how to packets go out of the host on a loopback interface.
Thanks in advance.
Comment: You should mention which OS you are using. You can't rely on all of them to behave the same. You should not be relying on 127.0.0.1 or the loopback interface for talking to neighbors.
Answer: A loopback interface on BGP speaking routers doesn't use only 127.0.0.1. It uses a routable address and can be used to reach a router regardless of what interface is used. This can be useful e.g. when configuring BGP sessions between two routers which have multiple paths between them, but you don't want to be specific on which interfaces are used.

Use of loopback Interface in iBGP


System-V message-queue PHP C++

Question: I am wondering what are the limitation of System-V message queue i.e. Maximum queue size, maximum size per item etc.
As I am working on integration of C++ with my PHP scripts and have very large amount of data which will be pushed into queue from php and C++ process will read that data on the other end.
I have devised an strategy in which i have 2 types of messages that will be written by php.
<code>1) Message length
2) Message data
</code>
But, I am facing unpredictable behavior in my C++ application which is responsible of reading length/data sequence.
Firstly, I am unable to write more than 6000 Bytes per msg_send from php, thats why I had to break my message into chunks lead by the complete message size. so my queue will look something like this (msgtype in parentheses)
Size(1) + Chunk(2) + Chunk(2) + Chunk(2) + Size(1) + Size(1) + Chunk(2) + Chunk(2)
Though, I am able to read a few chunks correctly, but in the middle of somewhere I start getting receive error and leaving some messages in the queue and rendering the queue just useless.
Answer: The limitations depend on your platform, OS version, and kernel parameters. You should consult documentation of your system. For example, you can get some info from msgctl() on Linux.

System-V message-queue PHP C++


How to do flame reflection on a wall?

Question: How can I light up this wall as if reflections from a fire? sort of a dancing light on the wall? I tried with an emission surface with a wave texture and colour ramp. but it doesn't seem to work. Any other suggestions? enter image description here
Answer: Rather than trying to emit flames onto the wall, animate the flame texture and mix it into the wall material.

Here I animated the z-location of the mapping node to "move" the wave texture and then multiplied it with the wallpaper colour.

Note that from 2.81, or daily builds until then, some of the texture nodes now have a time factor so we can properly animate the textures instead of moving through them using the mapping node.

How to do flame reflection on a wall?


How do I connect Leica Summicron-M 1:2/50 E39 lens to Canon EOS 5D body?

Question: Could anyone recommend what I need to buy in order to connect a Leica Summicron-M 1:2/50 E39 lens to a Canon EOS 5D body? Do I need a bayonet lens adaptor and if so please let me know which one?
Answer: This is not possible.  The flange distance of M mount is 27.8mm while EF mount is 44mm.  The lens would function as an extreme macro lens only on EF mount, so no one makes Leica M to Canon EF adapters.
Answer: There are no such adapters, because the Leica M lenses have a registration distance that would put the lens inside the Canon's body if you wanted to achieve focus to infinity.  Canon's mount distance from the sensor is roughly twice that of a Leica M's mount from the sensor/film plane.  The distance the lens is held is part of the mount system design and is critical for the lens to focus properly.
To shove the M lens into the Canon body and hold it at the appropriate distance, you'd probably also collide with the SLR's mirrorbox--something M-mount rangefinders don't have.
The only digital camera bodies that you can easily adapt Leica-M mount lenses for are the mirrorless cameras: Sony NEX (E-mount), Fuji X, and Olympus/Panasonic micro four-thirds cameras, where the registration distance is smaller than that of Leica M, and where you can use simple ring adapters.  Be aware, however, that even though you can get the registration distance to work, there is still the issue of sensor stack thickness, particularly with wider fast lenses.
See also: Can I use lens brand X on interchangeable lens camera brand Y?
Comment: that's interesting thanks. would sony RX1 body work?
Comment: or is it a fixed lens?
Comment: @SIa RX1 is a fixed-lens camera. One of the Sony A7 e-mount bodies is probably your only choice if you want full-frame. See: http://briansmith.com/sony-a7-a7r-lens-mount-adapters/. Most of the Sony e-mount and Fuji X cameras are 1.5x crop, while micro four-thirds is 2x crop, so the 50mm would have the FoV of a 75mm or 100mm would on film, respectively, on those bodies. On an A7, it'll have the same FoV that a 50mm would on film.


Who should I hire to remove the smell of cigarette smoke from my home?

Question: I bought a house that has had a cigarette smokers in it for 40 years. Would a general contractor be able to fix this?  Or do I need to first get a company that usually handles massive fire damage or something to remove the smell?  Does someone need to clean the HVAC stuff?
Answer: A general contractor is not needed for something like this.
A fire/smoke remediation company would likely be best to talk to, but this is pretty easy stuff to DIY for the most part. At a minimum, I would expect the HVAC needs cleaned very well, all air filters need replaced, every surface cleaned very well, carpet replaced, every wall/ceiling repainted (likely after putting a stain blocking primer on), and an air purifier run to help clean any lingering scents.
Comment: I'm not sure the HVAC can be DIY cleaned very well, at least not into the ducts anyways. The really thorough ones put robots down there and scrub it.
Comment: Not as an advertisement or endorsement, but [this product](https://www.kilz.com/primer/kilz-restoration) is a primer designed specifically for this purpose. I'm sure there are other brands and some may work better or worse than others.
Comment: @Nelson Well... at least as good as possible. Clearing out all the dust bunnies would be a great minimum.
Comment: @Nelson I'm wondering if a full duct cleaning is the best solution there too.  I have no experience with it, but I'd be worried about scrubbing at the stuff caked into the ductwork and not capturing it all.  Is there a risk of releasing more into the air through scrubbing than the air picks up from the duct?  Seems like the kind of thing you either want to do right ($$) or possibly skip that step unless the other steps dont remove the smell.  Though talking to a pro should also answer this.
Comment: Cigarette smells, mixed with moisture and dust, creates a permanent source of scent. I do IT work and smoker's computers are very nasty, as with any game consoles or other electronics. The ducts will be in the same condition and it would need to be cleaned, especially after four decades.
Answer: I have a rental and it had a smoker for many years. I rented an ozone generator. It worked! New tenant is a non smoker and couldn't smell tobacco. I rented it from local tool rental place. It looked something like this.
I also cleaned and painted everything.
Comment: Honestly, with the enthusiastic first paragraph, product link, and the small "I also cleaned and painted everything", this reads like an ad. Also: in what order did you do it, did you first run the ozone, or did you paint the walls first?
Comment: @UnhandledExcepSean I've read that ozone generators are useful for neutralizing smells.  Ozone doesn't 'purify' the air (it's toxic.) I understand the idea is to react with the odor causing molecules.  No one should be in the home/room while it's running and until the air in the room/house has time to turn over.
Comment: Did you run the ozone machine first and notice an immediate relief? Or had you cleaned and painted everything first? I've read (from fairly reputable sites) that the ozone machines are no better than a regular air purifier and can be a bit hazardous.
Answer: I happen to own a large commercial ozone generator that was used to remediate mold.  My wife's niece's apartment was inundated with smoke from a fire in a neighbor's apartment and they couldn't get ride of the subsequent smell.  They borrowed my ozone machine and it cleared out all odor problems in a day.
Answer: I think the answers above are good. I have no experience with ozone generators, but I'd just simply introduce some categories.

Really smooth surfaces can be washed with a TSP-substitute.
Painted walls can be prepped, primed, and painted.
Stone surfaces can be power washed.
Rugs can be scrubbed with a carpet cleaner.
Consider the use of HEPA filtration or ERVs.
Of course, anything can be rehabbed (or coated) if you're willing to accept the costs.

If you go the ozone route, be careful since O3 is a powerful oxidizer and is considered an atmospheric pollutant at certain levels, and let us know how it goes. (See also this article on how ozone generators are unregulated and their misuse can be toxic.) I'm not sure that you can generate enough ozone to strip a layer of nicotine from a wall, but who knows!


Rounding to fraction

Question: If I write the number 0.333333, you will immediately think to $1/3$. Somehow 0.333333 has been "rounded" to $1/3$. I wonder if there is a general way to find such fraction. So let's formulate the problem in a precise way. I suppose here that all numbers are positive. Given a real $a$ and an integer $n$, I want to find the reduced fraction that is closest to $a$ with denominator less than $n$. So this fraction approximates the real with an error at most $1/n$. Is there an efficient algorithm to find it (other than brute forcing it by checking all possible denominators).
Comment: Continued fractions will do a lot for you.
Comment: It is also worth checking the proof for https://en.wikipedia.org/wiki/Dirichlet's_approximation_theorem
Answer: I don't know what the best algorithm is, but assuming you are just working with rational numbers, then, turn it into an algebraic problem.
In this case it satisfies the equation,
\begin{equation}
10x - 3 = x
\end{equation}
which is easily rewritten as
\begin{equation}
9x = 3
\end{equation}
so that
\begin{equation}
x = \frac{3}{9} = \frac{1}{3}
\end{equation}
If you are working with real numbers, I believe the best rational approximation is given by turning your real into a continued fraction, as is suggested in the comments: https://en.wikipedia.org/wiki/Continued_fraction#Best_rational_approximations
Comment: You can start with a rational number but what you suggest is the standard way to convert a periodic decimal number into a fraction. This is not what I am looking for. In my example I mean **really** 0.333333 with six digits (not an infinity) which is not $1/3$. However, if you put $n$ to 1000 (so that the error will be less than $1/000$), the closest fraction to 0.333333 with denominator less than 1000 is $1/3$.
Comment: I have just fond that the programming language python has a function that does exactly that (limit_denominator). The source code has an interesting comment about the algorithm involved: https://svn.python.org/projects/python/trunk/Lib/fractions.py
Answer: Looking at the proof for Dirichlet's approximation theorem, the one which uses pigeonhole principle, we can define
$$a_i=i\cdot a - \left \lfloor i\cdot a \right \rfloor, i=0..n$$
thus each $a_i \in [0,1]$.
Then split $[0,1]$ into $n$ segments $[0,\frac{1}{n}]$,$[\frac{1}{n},\frac{2}{n}]$,$[\frac{2}{n}, \frac{3}{n}]$, ... $[\frac{n-1}{n},n]$, so we end up with $n$ segments and $n+1$ of $a_i, i=0..n$. According to the pigeonhole principle, two elements of $\{a_i\}$ will be within one such segment, i.e. $\exists i,j \in \{0,1,3,...,n\}, i \ne j$ (we can assume $j>i$) such that
$$|a_j - a_i| < \frac{1}{n}$$
or
$$\left|(j-i)a - (\left \lfloor j\cdot a \right \rfloor-\left \lfloor i\cdot a \right \rfloor) \right|<\frac{1}{n}$$
Then we note $\left \lfloor j\cdot a \right \rfloor-\left \lfloor i\cdot a \right \rfloor=m \in \mathbb{N}$  and $q=j-i < n, q \in \mathbb{N}$. As a result
$$|q\cdot a - m| < \frac{1}{n}$$
or
$$\left|a - \frac{m}{q}\right| < \frac{1}{n\cdot q} < \frac{1}{n}$$
I am not sure if this is the most efficient algorithm, because it's $O(n^2)$, although it may be improved with sorting to $O(n\ln{n})$.

Rounding to fraction


Any real valued continuous function from a closed bounded set in $\mathbb R^2$ is bounded and attains its bounds

Question: Without using the idea of compact or sequential compactness , can we prove that if $A$ is a closed bounded set in $\mathbb R^2$ , then any continuous function $f:A \to \mathbb R$ is bounded and attains it's bounds ?
Comment: Since this is wrong in infinite dimensional spaces, probably not. Somewhere in the proof you need something that's equivalent to compactness.
Comment: Can you use the fact that it's true for functions on closed bounded sets in $\mathbb R$?
Comment: How can we prove a topological property of the range of some functions without using topological properties of the underlying space?
Comment: @RobertIsrael : Yes , yes we can use that it's true for functions on closed bounded sets in $\mathbb R$
Answer: Since $A$ is bounded, take $R$ so $d(0,p) \le R$ for all $p \in A$, where $d$ is Euclidean distance.  In particular, the $x$ and $y$ coordinates of each point of $A$ are in $[-R,R]$.
Let $J = \pi(A) \subset \mathbb R$ be the image of $A$ under the projection $\pi: (x,y) \to x$ of $\mathbb R^2$ onto $\mathbb R$.  I claim this is closed.  To show this, suppose $x_0$ is in the closure of $J$.  For any $y$, let
$e(y)$ be the distance from $(x_0,y)$ to $A$, i.e. $\inf \{d((x_0,y), p): p \in A\}$.  Using the triangle inequality, $|e(y) - e(y')| \le |y - y'|$, so $e$ is continuous, and therefore $e$ attains a minimum on the closed, bounded interval $[-R, R]$.  But that minimum must be $0$, because for any $\epsilon > 0$ there is $(x,y) \in A$ with $|x - x_0| < \epsilon$, making $e(y) \le d((x_0,y), (x,y)) = |x - x_0| < \epsilon$.
If $e(y) = 0$, $(x_0,y)$ is in the closure of $A$, and therefore in $A$,
 so $x$ is in $J$.
Let $F(p) = \arctan(f(p))$.  Thus $F: A \to \mathbb R$ is continuous and bounded ($|F(p)| < \pi/2$).  It suffices to show that $F$ attains its supremum on $A$: if $\sup \{F(p): p \in A\} = F(q)$, then
$f(q) = \tan(F(q)) = \sup\{f(p): p \in A\}$ (and in particular $f$ is bounded above); similarly for the infimum, replacing $F$ by $-F$.
Let $s = \sup \{F(p): p \in A\}$.
For each positive integer $n$, let $A_n = \{p \in A: F(p) \ge s - 1/n\}$,
and $J_n = \pi(A_n)$.  Then each $A_n$ is closed and bounded, and so by the previous result $J_n$ is closed and bounded.  Moreover, $J_n$ is nonempty.
Define functions $g_n$ on $J$ so that  $g_n(x)$ is the distance from $x$ to $J_n$, i.e. $$g_n(x) = \inf \{|x - z|: z \in J_n\}$$  Then $g_n$ is continuous and bounded on $J$, with $|g_n(x) - g_n(x')| \le |x - x'|$.  Let $$g(x) = \sum_{n=1}^\infty 2^{-n} g_n(x)$$  Then
$g$ is continuous and bounded on $J$.  Now if $x \in J_m$, $g_n(x) = 0$ for all $n \le m$, so $g(x) \le \sum_{n=m+1}^\infty 2^{-n} (2 R) \le 2^{1-m} R$.  Thus the infimum of $g$ on $J$ is $0$.  By the one-dimensional result, $g$ attains its infimum, i.e. there is some $x_0$ such that $g(x_0) = 0$, and this means $x_0 \in J_n$ for all $n$.  That says
for every $n$ there is $y$ with $(x_0,y) \in A$ and $F(x_0,y) \ge s - 1/n$.
Now let $K = \{y: (x_0, y) \in A\}$, which is a closed bounded set, and on it define $h(y) = F(x_0, y)$, which is a continuous function.  By the preceding paragraph we see that $\sup \{h(y): y \in K\} = s$.
Again using the one-dimensional result, $h$ attains its supremum, i.e. there is some $y_0$ such that $F(x_0, y_0) = s$.  And this is what we needed to show.
Comment: That the intersection of $J_n$ isn't empty, looks suspiciously like Cantor's intersection theorem. That can be used to prove Heine-Borel ... :)


Cart Discount when applied to the cart doesn't show the correct amount in Order Total using Woocommerce in wordpress

Question: I have being creating a new woocommerce plugin that will provide an option to the apply discount on top of the cart page.
Now when there are products in the cart, the user will click on the Apply Discount button and when clicked and action is triggered from my custom plugin that will add cart discount to that particular Cart Order.
So far it works fine and also shows that cart discount applied. below is the screenshot

As you can see from the screenshot there the Order Total is showing Wrong figure calculated.
Below is the code from my custom woocommerce plugin file.
Following action is called when the button is submitted
if(!empty($_POST['apply_discount_woo'])){
                    add_action('woocommerce_calculate_totals',array(&$this,'cart_order_total_action'));
                }

and the function code:
public function cart_order_total_action(){
                if ( is_user_logged_in() ){
                    global $woocommerce;
                    global $current_user;
                    global $wpdb;
                    $u_id = $current_user->ID;
                    $table_name = $wpdb->prefix."woocommerce_customer_reward_ms";
                    $thetable2  = $wpdb->prefix . "woocommerce_customer_reward_cart_ms";
                    $table_name3 = $wpdb->prefix."woocommerce_customer_reward_points_log_ms";
                    $data       = $wpdb->get_row("SELECT * from $table_name where id=$u_id");
                    $data2      = $wpdb->get_row("SELECT * from $thetable2");
                    /* Order Id goes here */
                    $orders=array();//order ids
                    $args = array(
                        'numberposts'     => -1,
                        'meta_key'        => '_customer_user',
                        'meta_value'      => $current_user->ID,
                        'post_type'       => 'shop_order',
                        'post_status'     => 'publish',
                        'tax_query'=>array(
                                array(
                                    'taxonomy'  =>'shop_order_status',
                                    'field'     => 'slug',
                                    'terms'     =>'on-hold'
                                    )
                        )
                    );
                    $posts=get_posts($args);
                    //get the post ids as order ids
                    $orders=wp_list_pluck( $posts, 'ID' );
                    $order = $orders[0];
                    /* Order Id ends here */
                    if($data){
                        $user_points = $data->points;
                        $points_set  = $data2->woo_pts_set;
                        print_r($woocommerce->cart->applied_coupons);
                        echo $woocommerce->cart->discount_cart;
                        echo $woocommerce->cart->get_cart_total();
                        /* the line below adds the cart discount to the Cart */
                        $woocommerce->cart->discount_cart = $data2->woo_discount_set;
                    }else{
                        echo 'You dont have any woo points yet.!!';
                    }
                }
            }

How can I update the cart total on Cart Discount added?
Comment: Or is there another way, through which the cart Discount can be added.???
Answer: Maybe it's not 100% how you would like to achieve your goal, but you may generate a coupon on the fly:
$coupon_code = 'UNIQUECODE'; // Code
$amount = '10'; // Amount
$discount_type = 'fixed_cart'; // Type: fixed_cart, percent, fixed_product, percent_product

$coupon = array(
    'post_title'   => $coupon_code,
    'post_content' => '',
    'post_status'  => 'publish',
    'post_author'  => 1,
    'post_type'    => 'shop_coupon'
);

$new_coupon_id = wp_insert_post( $coupon );

// Add meta
update_post_meta( $new_coupon_id, 'discount_type', $discount_type );
update_post_meta( $new_coupon_id, 'coupon_amount', $amount );
update_post_meta( $new_coupon_id, 'individual_use', 'no' );
update_post_meta( $new_coupon_id, 'product_ids', '' );
update_post_meta( $new_coupon_id, 'exclude_product_ids', '' );
update_post_meta( $new_coupon_id, 'usage_limit', '' );
update_post_meta( $new_coupon_id, 'expiry_date', '' );
update_post_meta( $new_coupon_id, 'apply_before_tax', 'yes' );
update_post_meta( $new_coupon_id, 'free_shipping', 'no' );

Answer: After hours of research and debugging some Woocommerce Documentation. I found out that there are two types of discount that can be applied to the cart
1- Cart Discount
2- Order Discount
And correct me if I'm wrong, but discount is always applied on use of coupons. What I was trying here is to give a custom Discount of say $5 to the cart and this discount was not treated as an actual discount by Woocommere. Also this custom discount will not reflect the actual cart total on the cart page as well as the checkout page.
In order to do that you will ultimately have to alter your woocommerce class files, which I dont recommend when you are creating an independent custom Woocommerce Plugin.
But I figured out an alternate method of applying discount i.e with help of coupons. I created a custom coupon that will give a $5 discount to the cart. And that was it, Cart total recognised the dicount and showed me the correct total also the discount applied.
Also the checkout page was populated with the correct total.
And after processing the order it showed me the correct discount applied.
Just wanted to share this with you all. As I felt this was the solution that  worked like charm and without altering any of the woocommerce core files.
I hope this is useful to you all as well.
Thanks.
Comment: So did my idea help you resolving the problem?
Comment: @AttilaFulop - I already had figured out the solution before you posted your answer. Thankyou and I really appreciate your efforts.


Potential in the midway between parallel plates

Question: When we think of parallel plates with uniform charge density and charges $+q$ and $-q$,  and if we set the potential to be zero at infinity we find the negative charged plate's potential to be zero. But when we think of the charge on each plate as collection of point charges and try to find the potential just in the midway between plates by using $kq/r$ formula, the potential there seems to be zero. But this cannot be true because when we set zero potential to be at infinity and bring a test charge to the negative plate, we dont feel any force acting on the test charge hence the plate is at zero potential. What is the reason behind this contradiction?
Answer: I think the problem is in the first part itself where you take potential to be zero at infinity in case of a uniformly charged plate. Check this paragraph from Griffith.
Answer: You are mixing up "potential" and "force" or "electric field".  Force results from a gradient of potential: a change in potential vs distance traveled.  kq/r is the formula for potential around a point charge.  To find the potential around two infinite, parallel, charged plates it is necessary to do an integral of kq/r over the whole surface of both plates.  I won't go into the details.  The end result, though, is that the potential actually comes out to be kz, where z is the distance from one plate to the point where you want to find the potential.
The electric field strength is, in that case, constant between the plates; and the field points along lines perpendicular to the two plates.
On either side outside the two plates, the potential is the same everywhere. Because it doesn't change vs distance traveled, there is no electric field there.  Another way to look at it is that a test charge sees two infinite planes, both in the same direction but charged oppositely.  The electric fields from the two planes are equal and opposite, so they cancel out.  Between the plates, though, the two electric fields add together.
Comment: We need a drawing to refer to.  But if a point *positive* charge on one plate is paired up with a point *negative* charge on the other plate, the two potentials add; they don't cancel.  If both plates carried the same charge, then between the two plates the potentials would cancel  and outside the plates they would add.


Does the amount of oxygen in air, actually get lower as you go to higher altitudes?

Question: I have heard that there is less oxygen as you go higher (that's what my teacher told me). A reason that supports that is, as you go to higher altitudes, it becomes more and more difficult to breathe. But, I also read on the internet, that the amount of oxygen remains same but the air pressure drops, making it difficult for us to breathe. Which one is correct? Why?
Comment: TLDR: There is less _air_ at higher altitudes. The air becomes less _dense_ as you climb, but the _percentage_ of oxygen in the air stays the same.
Comment: @SolomonSlow the percentage of oxygen goes down as soon as you leave the troposphere.
Comment: @fraxinus, The chart in J. Murray's answer seems to suggest that the composition of the atmosphere is approximately constant all the way out to the official "edge of space" (100km). But even if there is some small gradient in the percentage of oxygen in the stratosphere and mesosphere, I'm guessing that's beyond the realm that the OP was asking about—the realm in which "it becomes more and more difficult to breathe." By the time you're in the stratosphere, you've gone _way_ past the point where the air is dense enough to sustain human life.
Comment: This image might help: https://imgur.com/dWyWsZy
Comment: See the link https://aviation.stackexchange.com/q/19486/ It basically is saying the same thing as other answers but this time from the point of airplane engine.
Answer: For elevations less than about 100 km (for reference, the peak of Mt. Everest is about 8.8 km above sea level), the relative concentration of oxygen in the air is fairly constant at about 21%.

Source
It's true that there's less oxygen (more specifically,the partial pressure of oxygen is lower) with increasing altitude - and this is simply because there is less gas overall.

Source
The reason it's difficult to breathe at higher altitudes is that the ability of your lungs to oxygenate your blood depends on the partial pressure of O$_2$ in your lungs when you take a breath. At sea level and under ordinary conditions, the partial pressure of O$_2$ in your lungs is approximately $21\% \times 100\ \mathrm{kPa} \approx 21\ \mathrm{kPa}$. This defines normal, at least in a limited sense.  If you're breathing pure oxygen, then you could potentially have an O$_2$ partial pressure of $100\ \mathrm{kPa}$, which can help compensate for damage to the lungs (e.g. from scarring) which reduces their ability to oxygenate blood - though as user Arsenal points out in a comment, under ordinary circumstances this would induce hyperoxia, which is bad news.
On the other hand, at the top of Mt. Everest the partial pressure in your lungs would drop to approximately $21\% \times 30\ \mathrm{kPa} \approx 6\ \mathrm{kPa}$ - nowhere near enough to sustain for extended periods, especially under increased physical stress. Breathing pure oxygen from a tank boosts this number to closer to $30\ \mathrm{kPa}$, which is why most climbers take their own oxygen with them.
However, above an altitude of 12 km (roughly the altitude at which commercial airliners fly) the pressure drops below $20\ \mathrm{kPa}$, which means that even breathing pure oxygen won't give you the normal required partial pressure of O$_2$, and you will risk hypoxia. That is why planes which fly above this altitude have positive-pressure respirators for pilots in case of emergency. Rather than being simply a higher concentration of oxygen, the gas in a positive-pressure respirator is (as the name suggests) actively pressurized above the ambient atmospheric pressure to force the required amount of oxygen into your lungs. See e.g. page 4 of this booklet from the US FAA and the associated regulations.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/132546/discussion-on-answer-by-j-murray-does-the-amount-of-oxygen-in-air-actually-get).
Answer: Well, both are related.
With lower pressure molecules tend to be less "packed" and so when you breathe you inhale less oxygen. Thus, the difficulty to breathe in really high altitude.
Answer: The amount of oxygen gets lower but not the concentration
The confusion in the question is based on a vague definition of "amount".
Most of the atmosphere below about 100km is well mixed (by the effect we call weather which ensures the relative proportion of gases in the atmosphere stays the same by turbulent mixing). Only in the rarefied higher atmosphere (10 times higher than Everest) do the effects of weather pter out and gravity can compete with diffusion causing some separation by the molecular mass of the gas.
But what does vary rapidly with height above sea level is the density of the atmosphere. At the top of Everest, the tallest mountain, the density of air is only about 1/3 of the value at sea-level. So there is only about a third as much of any component in the air. The proportion of oxygen is still about 21% but the amount of oxygen is only about 1/3 of the amount at sea level.
So any confusion arises because of the definition of "amount". If you mean the proportion of oxygen, it is the same as at sea level; but if you mean the absolute amount of oxygen, it is only ~30% of the value at sea-level. what matters for your ability to breathe is the total amount of oxygen per liter of air not the proportion of oxygen in each litre of air.
Some people refer to "amount" as the relative proportion, some as the total concentration. Hence the confusion.
Answer: Oxygen does get lower (in terms of percentage). It happens due density of oxygen. As we increase altitude relatively heavier gases stay down. Lower pressure rarely causes difficulty in breathing. It may cause nose bleeds or ailments related to high blood pressure. But due to less amount of oxygen we need to intake more amount of air which is seen as difficulty in breathing.
Check this site for altitude to oxygen chart
Comment: Mixing in the lower atmosphere keeps the relative concentration of oxygen in the air fairly constant until you reach altitudes greater than about 100 km.  It is *precisely* the lower pressure (not a decrease in the oxygen concentration) which causes hypoxia at higher altitudes - a condition called hypobaric hypoxia, as noted by the source to which you link.
Comment: Indeed the chart says "effective oxygen concentration". It seems they simulate the effect of barometric pressure by adjusting the O2 in an "air" at sea level.
Comment: I would expect that the oxygen percentage remains similar but the amount of oxygen per volume drops, as stated in the previous comment.


Photo in like box distorted

Question: I have embeded the Facebook Like box iframe on my web site and it's skewing/distorting the photos.  They are elongated.  They look fine on the actual Fb page, it's the embedded photos that are messed up.  It was not a problem until about 2 weeks ago.
Two samples:  www.photographsbyjim.com and www.riflesinc.com
Answer: They look perfect to me..
Answer: I've reverse-engineered the algorithm that Facebook are using, and it's quite complex. I don't know what they're thinking, but they undoubtedly intend for the distortion to happen.
As far as I can tell, only a picture 171 x 320 will not be distorted.
David
Answer: It appears to happen differently in different browsers. IE and Firefox display some photos distorted and Safari and Chrome are displaying different ones distorted.
Comment: This does not answer the question.

Photo in like box distorted


Training error remain unchanged when more feature vectors are added

Question: Given a vector of training data y and a corresponding matrix of features X (the ith row of X containing the feature vector associated with observation yi), why the training error (ie the mean squared error on the training set) of the least squares prediction will never increase as more features are added, according to linear algebra. Will the test error (ie the mean squared error on an independent test set) also never increase as more features are added ?
Answer: No; reducing a model's training error too aggressively can lead to test error increasing rather than decreasing. This phenomenon is called overfitting and is one of the primary obstacles to selecting good predictive models. Here's an example in R:
 set.seed(5)
 N = 1000
 d = data.frame(
     x1 = rnorm(N),
     x2 = rnorm(N))
 d = transform(d, y = x1 + rnorm(N))
 d.sample = d[1:5,]
 d = d[6 : N,]

 rmse = function(observed, predicted)
    sqrt(mean((observed - predicted)^2))

 m1 = lm(y ~ x1, data = d.sample)
 message("Training error: ", rmse(d.sample$y, predict(m1)))
 message("Test error: ", rmse(d$y, predict(m1, newdata = d)))

 m2 = lm(y ~ x1 + x2, data = d.sample)
 message("Training error: ", rmse(d.sample$y, predict(m2)))
 message("Test error: ", rmse(d$y, predict(m2, newdata = d)))

Adding the uninformative feature x2 decreases training error but increases test error.
Answer: Statistically,we  can say that the added features are useless.But we have to verify with the domain experts whether should we consider those features,as it may give some useful trend.
Hope this helps!!!


World's capital cities shapefile?

Question: I'm looking for a shapefile containing the locations of all the world's capitals as of (around) 2016?
Answer: Natural Earth provides a populated places layer which has a capital attribute.
Answer: Another obvious place to get names and location is the geonames website. If you go to the download page you can download data just as cities or the whole dataset which includes everything.

World's capital cities shapefile?


Pull back of Spin$^{\mathbb{C}}$ bundle

Question: Let $M$ be a closed $4$-d Riemannian manifold and $Z$ be its twistor space of $M$, i.e., the bundle of almost complex structures on $M$. Let $V$ be a Spin$^{\mathbb{C}}$ bundle, $V_+$ denote the positive spin bundle. We know $Z$ admits more than one almost complex structure. So it can have canonical Spin$^{\mathbb{C}}$ bundle once we fix an almost complex structure and we can have other Spin$^{\mathbb{C}}$ bundles by twisting it with a complex line bundle. Now let $\pi:Z\rightarrow M$ be the projection. Can we realize $\pi^*(V_+)$ as a sub-bundle of some Spin$^{\mathbb{C}}$ bundle of positive spinors on $Z$ and if yes how?
Comment: What do you mean by a Spinᶜ bundle? If it is a vector bundle with a reduction of structure group from $GL(n)$ to $\operatorname{Spin}^c(n)$, this will be impossible for $n$ large enough by a simple dimension count. If it is the (positive and negative) spinor bundle defined by a Spinᶜ-structure, this should follow from the splitting of $TZ = \pi^* TM\oplus L$, where $L$ is the second power of the complex line bundle whose fiber over $Z$ are (positive) spinors annihilated by the Lagrangian in $TX$ defined by the almost complex structure $Z$.
Comment: @BertramArnold I meant the positive spinor bundle defined by a Spin$^\mathbb{C}$ structure. Can you please explain a bit about your comment as an answer? Also, I think you meant $M$ instead of $X$. Notice $\pi^*(V_+)$ is a complex line bundle on $Z$ of dimension $2$.
Answer: $\newcommand{\spinors}{\mathbb{S}}$The tangent bundle $TZ$ fits into an exact sequence
$$
0\to T_{/M}Z\to TZ\xrightarrow{\pi_*}\pi^*TM\to 0
$$
where the fiberwise tangent bundle $T_{/M}Z$ is two-dimensional and equipped with a canonical complex structure. Explicitly, the fiber of $Z\to M$ over a point $m$ are the (oriented) complex structures on $T_mM$, which are isomorphic to the projective line of the two-dimensional complex bundle $\spinors_+(M)\to M$ of positive spinors (which you denote by $V_+$). Note that this projective line is defined without the choice of a spin structure, as the action of $\operatorname{Spin}(4)\cong SU(2)\times SU(2)$ on $\mathbb{CP}^1$ factors through projection of the first factor to $PSU(2)$ and therefore descends to $SO(4)$. The isomorphism sends a complex structure to the line of spinors which are annihilated by Clifford multiplication with vectors $v\in T_mM\otimes\mathbb C$ which are antiholomorphic with respect to the chosen complex structure.
The exact sequence splits using the Euclidean metric on $TZ$, whose existence you take for granted when you talk about the spinor bundle of $Z$; to be precise, the splitting can be obtained via the Levi-Civita connection, with the metric on $TZ$ defined as the orthogonal sum of the induced metric on $T_{/M}Z$ and the pulled back metric on $M$. The fiberwise tangent bundle has a complex structure from the description of the fiber as the projective line of a complex vector bundle, and the pullback $\pi^*TM$ has a canonical complex structure by definition of $Z$. It follows that the sum $TZ$ has a (almost) complex structure as well.
The spinor bundle of the sum of two even-dimensional vector spaces is the tensor product of the respective spinor bundles. This shows that $\spinors_+(TZ)\cong \spinors_+(T_{/M}Z)\otimes \pi^*\spinors_+(TM)\oplus\spinors_-(T_{/M}Z)\otimes \pi^*\spinors_-(TM)$. Thus we can realize $\pi^*\spinors_+(TM)$ as a subbundle of the positive spinors on $Z$ if $\spinors_+(T_{/M}Z)$ is trivial, which we can achieve by a judicious choice of Spinᶜ-structure on the vertical tangent bundle, coming from a $PU(2)$-equivariant Spinᶜ-structure on $\mathbb{CP}^1$; it is an easy exercise that such Spinᶜ-structures are in bijection with the integers, with the positive spinor bundle given by the line bundle $\mathcal O(k)$ and the negative spinor bundle given by the line bundle $\mathcal O(k+2)$, which can be made equivariant iff $k$ is even, so that we may take $k = 0$.
Comment: @BertramArnold +1 for the answer but your description slightly disagrees with my intuition. So, at a point $m\in M$ and say $J$ being an almost complex structure at $m,$ $V_+=L_J\otimes(\Lambda^{0,0}\oplus \Lambda^{0,2}_J),$ where $L_J$ is a line depending on $J$ now as we pull it back to $Z,$ there should be a twisting somewhere as we are kind of varying the pull back as $J$ varies. Your description straightaway nullifies the varying over the $J$ part, which kind of contradicts with my understanding.
Comment: I guess the intuitive picture is that the line $L_J$ depends on the choice of Spinᶜ-structure on the fibers; as I explained, it is exactly the positive spinor bundle of the fiber, which can be taken to be trivial. Note however that it is not possible to simultaneously realize the (pullback of the) positive and negative spinors as subbundles of the positive spinors on $Z$, as the positive and negative spinor bundle of the fiber are line bundles whose degrees differ by $2$.
Comment: Can you clarify *"different choices of spin structure are related by an isomorphism which acts by a scalar multiple of the identity on..."*, because $\mathbb S_+(M)$ is attached to a given spin structure, so when you have two different spin structures I don't know what map you're talking about and how their projective lines are isomorphic.
Comment: Right, sorry - locally, there's a unique spin structure which has a nontrivial automorphism, which acts by $-\operatorname{id}$ on the spinor bundle and therefore trivially on its projective line. I updated the answer to clarify this point.

Pull back of Spin$^{\mathbb{C}}$ bundle


Bypassing thermostat,

Question: It is hot and my AC isn't turning on. I bypassed the thermostat at the furnace, and the AC came on. How long can I leave the thermostat jumped? It is late and I can't replace the thermostat until tomorrow night. I need to sleep and have the house a little cooler for my dogs throughout tomorrow. I plan on unjumping it before I leave the house in the AM.
Answer: If your AC unit was running correctly before the thermostat failed, then it will be OK to run it continuously until the AM when you plan to shut it off. Just don't freeze tonight because it won't be cycling on and off. When weather is extremely hot, AC units can run continuously and many do down here in South Florida. Just replace the thermostat as soon as possible.
Answer: Imagine you had a working thermostat and you flipped it to "A/C" and set the temperature to 50F.  The thermostat would "call for cooling" so long as the temperature is above 50F.  Since I bet your system would never get there, that means it would "call for cooling" continuously. That is fine.  If your heat pump unit can't run continuously, then there should be protective circuit built into its internal controller.
So, the idea of "call for cooling" all night is legitimate.
To call for cooling, the thermostat shunts (i.e. shorts) (i.e. jumpers) terminals R and Y.
If you were to jumper R and Y yourself either at the thermostat or at the furnace, that would be the same thing.
The only difference is the furnace is full of Very Bad Things you must never, ever jumper to.  Easy to make a mistake there and set something on fire.  Whereas, at the thermostat you can't get in too much trouble.  (worst thing you can jumper R to W and R to Y and call for both A/C and heat at once lol.)
Also, jumpering at the thermostat proves out the thermostat cable.

Bypassing thermostat,


How to create Banner in sharepoint?

Question: I want to create the banner in sharepoint as shown below:
Answer: This is quiet easy. Edit the page you want to modify.
Select "Text Layout" from "Format Text" ribbon and set it to "Two columns with header" or another layout having a full width element on top.

Now select the ribbon "Insert" and insert a picture.

Now as you selected or uploaded a picture select the picture ribbon. Make sure the horizontal size is on 100% to fit the SharePoint page at all times. I used a logo with 256x256px which I wanted to stretch horizontaly but not verticaly so I disabled "Lock Aspect Ratio".

Save the page and you got your banner on top fitting all common display resolutions.
Comment: Thanks a lot, but I have old share point where I cant see these options. Is there any other way to find out
Comment: What version of SharePoint are you using?
Comment: SharePoint 2013. Is there anyway to achive this using designer ?
Comment: I would not do it by Designer. Try to edit the page and set a "Content Editor Web Part" on top. In that you can insert the picture as shown above. Can you do that?
Comment: Hi I tried the above option by creating new page and then got those option, however am not able to convert the image as banner like I showed in the pic.

For example in the above image, the header image is changed as banner and on top I could see the sharepoint site name.
Comment: Ok, so I do not know how to help you - I am sorry. Maybe the other answer helps...
Answer: For SharePoint 2013, you could follow the steps in this blog with SharePoint Designer:
How to Add a Site Banner in SharePoint 2013
Answer: If you want, You could try using "Content Editor" web part and insert HTML Snippets.
You could do so by add a "Content Editor" web part. Afterwards click the upper right corner of the web part and click "Edit Web Part". Now click "Edit Snippet" and insert your HTML Snippet. click apply and click ok.
Comment: Sorry I didn't get your point, Basically I just need to change the background of this area
Comment: you could try editing the css. use the same process as above. Add a "Script Editor" then paste the CSS.
Answer: I used Sharepoint Designer.
You have to create an html page from the master page. Add the header reference to the html master page. (basically it's the editable file linked to the master page).

Look for the "s4" divs and place it between them accordingly.
Set up your CSS for the banner then link the .css file in Master Pages under Site Settings.
Answer: I look at Banners as being good for announcing things that people just can't miss. Something like this for example:

There are a couple of different ways you can add a true 'Banner' on top of SharePoint to highlight information.
1) Use the ways that other folks have talked about here which is things like using Content Editor web part, SharePoint Designer, Script editor, etc. to truly embed the banner directly into SharePoint
2) Use programming (javascript mostly) or a 3rd party platform like VisualSP to overlay a banner on top of SharePoint. That way you are not really moving around the content on the page, but just overlaying your important message on top of it so it can't be missed.
Good luck!

How to create Banner in sharepoint?


Why is the amino acid cysteine classified as polar?

Question: Cysteine amino acid has an embedded sulfur group in its side chain. Looking at the electronegativity difference of hydrogen and sulfur, it can be considered a non-polar side chain because the electronegativity difference is less than 0.5. This makes it non-polar but still we put it in polar category, why?
Comment: https://chemistry.stackexchange.com/questions/121570/comparing-polarity-of-amino-acids
Answer:
[...] we still put it in polar category

If you search for amino acid classification, you will find that there is no agreement on how to classify cysteine.
What you should know is that cysteine has different roles in proteins. In cysteine proteases, it acts as a nucleophile (and its surrounding often makes it more prone to deprotonation compared to a netural aqueous environment). Cysteines that form disulfide bonds often are at or near the surface of the protein; once the disulfide is formed, you have a quite hydrophobic group. Protonated cysteine is incapable of making conventional hydrogen bonds, and the electronegativity of carbon and sulfur are quite similar. This explains why methionine, the other sulfur-containing amino acid, is classified as hydrophobic.

[...] , why?

The classification of amino acids is sometimes used as proxy of the tendency of amino acid side chains to be located on the surface or in the interior of a protein. Similarly confusing, proline is sometimes classified as polar amino acid; however, its side chain is made exclusively of carbon and hydrogen atoms. If you study where proline is mostly located with a folded protein, you find it is on the surface. This is not because proline is polar but because it is a helix and strand "breaker", so it is often found in turns, which are mostly on the surface of the protein.
Also, you should know that there is no all-or-nothing classification of every amino acid side chain. Tyrosine, threonine, even lysine have hydrophobic parts while being capable of making hydrogen bonds. Often, the environment is just right, with hydrophobic parts interacting with other hydrophobic parts, and all hydrogen bond potential satisfied, either by interactions with other side chains, with main chain or with solvent.
Why is cysteine not classified in a more consistent manner?
Here is an excellent starting point to answer this question, starting with the abstract:

Cysteine (Cys) is an enigmatic amino acid residue. Although one of the least abundant, it often occurs in functional sites of proteins. Whereas free Cys is a polar amino acid, Cys in proteins is often buried and its classification on the hydrophobicity scale is ambiguous. We hypothesized that deviation of Cys residues from the properties of a free amino acid is due to their reactivity and addressed this possibility by examining Cys in large protein structure datasets. Compared to other amino acids, Cys was characterized by the most extreme conservation pattern, with the majority of Cys being either highly conserved or poorly conserved. In addition, clustering of Cys with another Cys residue was associated with high conservation, whereas exposure of Cys on protein surface with low conservation. Moreover, although clustered Cys behaved as polar residues, isolated Cys was the most buried residue of all, in disagreement with known physico-chemical properties of Cys. Thus, anomalous hydrophobic behavior and conservation pattern of Cys can be explained by elimination, during evolution, of isolated Cys from protein surface and clustering of other Cys residues. These findings indicate that Cys abundance is governed by Cys function in protein rather than by the sheer chemical and physical properties of the free amino acid, and suggest that high tendency of Cys to be functionally active can considerably limit its abundance on protein surface.
Comment: Sir Karsten Theis, first I say thanks to you for your answer.. but if we consider cysteine polar just because its side chain ionize in aqueous medium than another question arises and that is.. The S-H bond in cysteine is non polar because the electronegativity difference between H and S is less than 0.5 which make the bond non polar so how this group ionizes in water which is a polar solvent?.. why hydrogen gives its own electron to sulfur which is not as powerful as oxygen or fluorine?
Comment: See https://chemistry.stackexchange.com/q/128046
Comment: And https://chemistry.stackexchange.com/a/27815


SVD Silent Columns Span Null Space

Question: I am trying to better understand SVD, and I have been struggling for a week now trying to understand this. Given the SVD of an $m \times n$ matrix $A = U \Sigma V^T$ where $m>n$, how do I show that the silent columns of $V$ span the null space of $A$. If $m=n$ or $n>m$ will the proof be different. Everything I look up states that facts about the null space and range of $A$ given the SVD, but the proofs are not presented.
Comment: In your notation, is $U \in \mathbb{R}^{m\times m}$ and $V \in \mathbb{R}^{n \times n}$?
Comment: Yes. That is correct.
Answer: Let the columns of $V$ be $v_1$, $v_2$, $\cdots$, $v_n$. Without loss of generality, we assume that $v_{k+1}$, $v_{k+2}$, $\cdots$ and $v_n$ are the silent columns of $V$. Therefore, $A$ can be written as
$$
A = U_k\Sigma_k V_k^T
$$
where $\Sigma_k$ contains only non-zero singular values of $A$ and $V_k$ contains $v_1$, $v_2$, $\cdots$ and $v_k$ as columns. That is, $\mathsf{rank}(A) = k$. Moreover, we have
$$
Av_i = U_k\Sigma_kV_k^Tv_i = 0
$$
for each $k < i \leq n$ becaue $v_i^Tv_j = 0$ for $i \neq j$. Therefore, $\mathsf{nullity}(A) \geq n - k$.
By rank-nullity theorem, we have
$$
\mathsf{rank}(A) + \mathsf{nullity}(A) = n
$$
we conclude that $\mathsf{nullity}(A) = n - k$ exactly. That is, $v_{k+1}$, $v_{k+2}$, $\cdots$ and $v_n$ in fact spans the null space of $A$.
Comment: Thanks! This was very clear and concise proof. I can now understand why these columns span the null space instead of just believing.
Comment: Do the v's that span the nullspace (the silent vectors of V) come from directly the eigenvectors of $V^TV$? Or must they be constructed *from* those eigenvectors?

SVD Silent Columns Span Null Space


quadcopter specification

Question: https://www.droneassemble.com/product/quadcopter-drone-90-minutes-endurance/ This quadcopter offers a 90-minute flight time on a 14S-14000mah Li-ion battery. The propellers being used have a 22-inch x 8-inch blade and an 8 kg MTOW. Is this specification sensible? If so, could you please explain how?
Answer: I'd guess it can only do 90 minutes at it's minimum weight (5.4kg) and loading it up to 8kg would halve the flight time.
Compared to a DJI Mavic, it's got about 20 times the rotor area, and 10 times the battery energy. It weighs 5-10 times as much, so it's reasonable that it could double the Mavic's 45 minute duration.
Of course, a much cheaper way to fly for 90 minutes would be to buy a second battery for a cheaper drone.

quadcopter specification


Localization of a point on a line in QGIS

Question: I'm relatively new to the GIS field. I have several polylines (streets) and would like to locate stations on these lines. The start and end points of the lines, the length of the line and the distance of the stations from the starting point are given. I'm looking for the coordinates for the stations. With GRASS and PostGIS there are probably possibilities. Does anyone have good explanations?
Comment: Possible duplicate of [QGIS Linear Referencing](https://gis.stackexchange.com/questions/130307/qgis-linear-referencing)
Answer: In QGIS Built-in functions (I think since the 3.0 version), it is a function for do what you want :

fonction line_interpolate_point
Returns the point interpolated by a
  specified distance along a linestring geometry.
Syntax
line_interpolate_point(geometry, distance)
Arguments
geometry : a linestring geometry
distance : distance along line to interpolate
Examples
geom_to_wkt(line_interpolate_point(geometry:=geom_from_wkt('LineString(0
0, 10 0)'),distance:=5)) → 'Point (5 0)'

In your case, add two real fields (one for x_coords, and one for y_coords) to the line layer, go to the field Calculator and for update the x_coord field with :
x(line_interpolate_point($geometry, "station_distance_field"))

and y_coord field :
y(line_interpolate_point($geometry, "station_distance_field"))

With PostGIS, I think the result can be found with the function ST_LineInterpolatePoint.
The first argument is a line / polyline geometry and the second one, the fraction of total linestring length from the start point.
If you have the distance of the station and the length of the line (cf. ST_Length), you can have the second argument.
EDIT
Based on your comment, and for example, open a python console and run in the editor the following code, creating a memory line layer with 3 features :
vl = QgsVectorLayer("linestring?crs=EPSG:3044\
&field=route_name:string(50)\
&field=length:integer\
&field=Startingpoint:string(70)\
&field=Endpoint:string(70)\
&field=Distance:int8",
          "line_layer",
          "memory")

pr = vl.dataProvider()
ft = QgsFeature()

ft.setGeometry(QgsGeometry.fromWkt("LineString (753979 5779912, 729900 5699907, 687178 5651749, 675527 5640874)"))
ft.setAttributes(['route_1', 163829, '', '', 50])
pr.addFeatures([ft])

ft.setGeometry(QgsGeometry.fromWkt("LineString (450270 5842052, 519401 5861471, 641350 5824964, 651448 5802438, 650671 5741075, 583871 5657186, 447940 5664177)"))
ft.setAttributes(['route_2', 528657,'', '', 100])
pr.addFeatures([ft])

ft.setGeometry(QgsGeometry.fromWkt("LineString (416093 5581065, 541927 5580288, 598629 5535237, 622708 5466106, 632029 5428822, 693392 5395422, 725239 5400083)"))
ft.setAttributes(['route_3', 412041, '', '', 200])
pr.addFeatures([ft])

vl.commitChanges()

QgsProject.instance().addMapLayer(vl)

Comment: The direction seems to be right. Unfortunately, no value is generated. My distance field is defined as real. Is that correct? Would I have to add a starting point to the function?
Comment: Have you replaced, in the proposal code, the "station_distance_field" by your distance field ? What's the projection (CRS) of the line layer and what's the units of the real values of the station distance ?
Comment: The projection is EPSG:3044 - ETRS89 / ETRS-TM32 and the units are meters. Structure of the table is the following: Field 1 = name of the route (string); Field 2 = length (integer); Field 3 = Startingpoint (String); Field 4 = Endpoint (String); Field 5 = Distance (Integer64)
Comment: Can you test the code I've added in the post and tell if the functions work ? I use `x(line_interpolate_point($geometry, "Distance"))` and it's work perfectly.
Comment: It does not work.
execfile(u'c:/users/schrei~1/appdata/local/temp/tmp2vtycu.py'.encode('mbcs'))
Traceback (most recent call last):
  File "", line 1, in
  File "c:/users/schrei~1/appdata/local/temp/tmp2vtycu.py", line 27, in
    QgsProject.instance().addMapLayer(vl)
AttributeError: 'QgsProject' object has no attribute 'addMapLayer'
Comment: Do i have to change in the script?
Comment: I've forgot a question : what's the QGIS version used ? I test it on version 3.4 .
Comment: Now i used 3.0. There it works! Now i have 3 lines with different distances
Comment: Unfortunately, the field calculator does not work here either. Syntax is correct, but always comes null.
Comment: I don't understand, with the memory vector layer, I create `x_coords` field with real type and update it with the formula, and it gives me results.
Comment: It works! I forgot a value


Unity Android: How can I ensure quality on splash image display?

Question: How can I ensure that the splash screen image in my Unity Android project is excellent at all resolutions?
Since Unity only allows me to specify one texture to use as a splash screen, and since Android devices come in a variety of resolutions, the texture will have to scale up or down to fit the screen.  Unfortunately, Unity's downscaling produces a chunky-looking low quality result on screens that are lower resolution than the image.  On the other hand, images smaller than the screen resolution scale up well, but are of course more fuzzy and anti-aliased due to their lower resolution.
Is there perhaps a way to alter the splash screen display at the Android OS level, or some other solution for this issue?
Thank you,
Bill
Answer: If you can you can try converting your splash image into a 9 patch.
9 patch tool
9 patch guide
I hope it helps..


Citing the results of other peoples experiment in my own work

Question: I'm doing a research for my bachelor degree final project and it contains no experiments.
I found a paper which has published results of an experiment and their data and images/diagrams are so relevant to the subject of my work.
Is it kind of plagiarism if I use their data and images even with referencing to their paper?
Comment: If you cite the papers and explicitly mention that this result is obtained by XYZ et al [*] then it is not plagiarism. However, I don't think it is good for your thesis from a quality perspective.
Answer: If you cite their work, then it isn't plagiarism. You just make clear what things, especially ideas, came from them and which are your own. Plagiarism isn't about reuse, but about misattribution.
However, you may have to deal with copyright as well which will limit how much of what they say can be part of your paper. But quoting brief passages (with citation) is fine, as is pointing readers of your work to theirs.
Images, however, are a special copyright problem, since an image can be considered a "work" in its own right separate from the paper in which it occurs. To copy such images you may need to get permission from the copyright holder (as well as cite). You can create your own images from the original data, but not so similar as to be considered infringing.