UI Design Patterns

Question: I have been reading about MVP, MVVM and have used asp.net MVC in couple of practice projects. These patterns are mostly referred to as UI patterns, which is bit confusing for me, since I used to think that only Views (in MVC) are the UI and the Model is data access layer + BLL.
My question is if I use Entity Framework (edmx) as my Model, why would I need to have a separate layer for data access (DAL) and what would this data access layer actually do in this scenario.
Comment: A neat project to look at for a good example of incorporating several design patterns like MVC, separation of concerns, IoC, independent unit testing, etc. is Silk: http://silk.codeplex.com/
Answer: MVC and the others are considered UI/presentation patterns because their primary mission is to accept requests from an outside source and display results.  The M portion of those patterns generally refers to simple models that are used as DTOs (data transfer objects) that help populate the views (also known as view models).
Business logic, if it's more intense than just CRUD operations, is generally separated out from this.  That allows different kinds of front-end apps (an MVC site here, an actual phone/tablet app there) to interact with the data in different ways.
In other words, MVC and the like are really just a skin on top of the business logic that actually does stuff.
You'll need to ask yourself if it makes sense to separate out your EF portion from the rest of your project.  If you're doing more than just CRUD operations on your data, I'd say yes.
Answer: You don't explicitly need a separate DAL, since EF is your data access layer and model at the same time. If you us POCO's for your model, you need a layer to handle the persistence of these objects. So if you use NH as OR/M, then your model simply consists of POCO objects and NH is your DAL. Usually NH is hidden in a separate layer, but this isn't really necessary. If it comes to the GUI, the your entities aren't used directly for binding etc. The MVVM introduces the ViewModel for it, that functions as layer between the GUI and the Domain Model and provides all the data from the model that is needed by the GUI.
Answer: Actually both views and controllers deal with UI. Basically, everything except Model Layer, is for and about UI. And you must understand, that things like REST API also are just a different kind of user interface.
As for your research, i would recommend for you to take a harder look at Model2 MVC and HMVC as patterns. Former is the closest thing to classical MVC, that you can do for web. And the latter has very interesting use-cases and solves re-usability problems (and also has some potential in distributed systems).
Now for the main question.
You separate domain business logic (in domain object) from data access logic (in datamappers), because you gain following features:

code decoupling, separation of concerns
ability to unit-tests independently

Basically, this lets you have codebase, where addition of a specific change (like adding cache, or model level authorization checks)  do not require you to rewrite whole codebase.
Also the storage mechanism itself becomes a lot more flexible. You can easily change where your data for a specific domain object is stored. For example, you can move user details and authentication to a noSQL database. This would not have ANY impact on how your business logic works. This becomes a critical issue, when you are working in larger teams or maintain old code, because it is very hard to grasp whole system and keep this knowledge up-to-date.
As for what the data access layer does: it takes domain objects (the things, that contain domain business logic) and either stores data from them or retrieves information into them for data source layer.
Also, i would recommend to research/watch:

SOLID principles
Unit testing (I would recommend to watch all the lecture from Clean Code Talks)

Disclaimer: my primary language is PHP, and only have experience with MVC-related patterns in the context of web (mostly with the Model2 variant of it, because of the obvious limitations of web itself), which has shaped my understanding of MVC structure.

UI Design Patterns


What are the other two common pentatonic scales

Question: An answer on my previous question mentioned 2 other common pentatonic scales besides the 'common blues' scale.
I'm guessing one of them is the major pentatonic scale, but what is the other one, and how/where is it used?
Comment: Doc - please ensure all relevant info is in the question, rather than requiring folks to figure out what your numbers mean (especially challenging when you have incorrectly written them down) - also, none of the answers mention 2 other scales. One does mention various other scales, though.
Answer: You question linking is confusing. The linked question doesn't even have the word "two" in any part of the page.
Anyway, the two common pentatonic scales are major pentatonic ^1 ^2 ^3 ^5 ^6 and minor pentatonic ^1 ♭^3 ^4 ^5 ♭^7. But the two scales are really just the same set of tones with an changed tonic. ^6 in major becomes the ^1 in minor and vice versa. You could say the minor scale is the relative minor or the major pentatonic scales.
Both scales can be seen as subsets of a diatonic scale. This is the so-called "gapped scale" description of pentatonic scales you sometimes see.
If you put a half step between the ^2 ^3 in major or ^4 ^5 of minor you get the basic blues "scales."
These aren't the only pentatonic scales. Any 5 notes scale could be called a pentatonic scale. But these are the common western pentatonic scales.
Answer: There is really only 1 type of (Tonal) Pentatonic Scale with 2 different tonal (variations) qualities, a Maj. or (Nat.) Min. which are also all relative Maj./Minor to each other (the same as with Heptatonic or 7 note scales). These Pentatonics, all of which are constructed out of Anhemitonic intervals (no halftones); (1) Major Pentatonic (1, 2 , 3 , 5 , 6) and (2) The Minor Pentatonic (1,♭3 , 4 , 5 , ♭7). Not to confuse "Types" as in different categories with "Same Type Variations".
The common "Minor Blues Pentatonic" scale (is considered to be a "modal scale") and is not really a pentatonic scale as it actually contains 6 notes (Hexitonic), which is sometimes referred as a pentatonic +1 scale (which contains a halftone or chromatic tone also known as a "blue note" a ♭5 (1, ♭3, 4, ♭5, 5, ♭7 ). This is also the same with the "Major Blues Pentatonic" (a Hexitonic scale or pentatonic +1), it contains a ♭3 (the "Blue" note) in it, (1, 2,♭3, 3, 5, 6 ). Both the Major/Minor Blues pentatonic scales are the modes of each other  BUT are very often used in Tonal music AND belong to a subset of "Tonal Scales" known as the Hexatonic / Heptatonic and Nonatonic "Blues Scales".
This leads us to the 2nd kind (type) of 5 note Pentatonic (Modal) which has 2 variations, the 1st is called the "Pentatonic Modes" and the 2nd is called the "Modal Pentatonics" /AKA: Modes Of The Pentatonic) which are both completely different in function and not to be confused (which most people do) as being the same thing. The "Pentatonic Modes" are 5 note pentatonic scales (Ionian(Maj.)/ Dorian / Phrygian / Mixolydian and Aeolian (Nat.Min.) ) BUT they can and MUST be re-arranged to fit the given mode, this is something that is often overlooked or not even known (exception Ionian and Aeolian, which remain as anhemitonic intervals and maintain the tonal or "parental" pentatonic shapes) the others can and do consist of hemitonic intervals (containing halftones). Some of the Pentatonic scales mentioned here in the answers belong to the "Modal Pentatonics" type (Egyptian, Blues Major/ Blues Minor-etc.), which are all simply subsets belonging to one of the 2 general main pentatonic mode variation types- (both very often used in Jazz and other Modal Music). The "MPs" sometimes do have names but are often simply noted as Mode 1, Mode 2, Mode 3-etc. This is because with this type of mode there are 5 possible Mode types that all use the exact same "Final" or "Modal Home Tone", i.e. the 5 Modes of the C-Maj. Pentatonic scale; Mode-1(Maj.Pentatonic) C-2-3-5-6 / Mode-2(Egyptian) C-2-4-5-♭7 / Mode-3(Minor) C-♭3-4-♭6-♭7 / Mode-4(Ritusen or Suspended)C-2-4-5-6 and Mode-5(Minor Pentatonic)C-♭3 , 4 , 5 , ♭7. As you can see in the main 2 types of Pentatonics (including all the given variations), 1-Tonal and 1-Modal both with 2 variations each (not withstanding that both contain numerous subsets with numerous supersets or sub-variations, especially as far the modes are concerned), that the Maj. and (Nat.) Minor pentatonic never change their interval structure when it occurs naturally as part of any given mode. I just wanted to mention this  pentatonic mode type but won't go any further into it as this can get very involved and was not part of your question.
The answer to your last question how the minor pentatonic scale is used, there are 4 very common possibilities (1) simply over minor progressions, including Blues based in a minor key (2) i.e. very often in blues music with progressions based on dominant tonic chords or chords / progressions containing a Dom7 (9/11/13-etc.) (3) over an Aeolian Modal Chord Sequenz (this mode is an exception in this case: the pentatonic mode shape remains exactly the same as the none modal pentatonic shape)(4) Both The corresponding Maj./(Nat.)Minor unaltered Pentatonic scale can be used over any of the CMaj. Modes without any problems EXCEPT the scale / solo / melody will not be in modal context (exception Ionian and Aeolian), it will allow you to avoid or prevent you from playing modally regardless if the chord sequence or backing music has been arranged and played modally.
Answer: There are a variety of different pentatonic scales. "Pentatonic scale" refers to any scale containing five different pitches.
There are five pentatonic scales that are all derived from the same set of notes:

Note names | Scale name              | Major scale degrees

C D E G A = Major pentatonic         = 1 2 3 5 6
  D E G A C = Egyptian pentatonic    =   2 3 5 6 1
    E G A C D = Blues Minor          =     3 5 6 1 2
      G A C D E = Blues Major        =       5 6 1 2 3
        A C D E G = Minor pentatonic =         6 1 2 3 5

The above pentatonic scales are distinguished by the fact that they contain no semitones. The term anhemitonic, which means "containing no semitones" is applied to these scales. The consequence of this property is these scales do not contain the harshest dissonances found in, for example, major scales: the semitone, the tritone, and the major seventh.
One can also construct pentatonic scales that include one or more half-steps. They're called hemitonic scales.
Pentatonic scales are found in music spanning from ancient to modern and in cultures across the globe. In modern Western music, the above listed scales are very common in blues, jazz, and rock. Wikipedia's article on pentatonic scales contains a very good list with links to additional articles on the musics of various cultures and styles.

The above-linked article is the primary source for this post.
Comment: Since the five shown all have the same five notes, in different orders, would they be better labelled as pentatonic *modes*?
Comment: I don't know who invented the names "blues major" and "blues minor", but those pentatonic modes don't have much use in the blues, and that's a euphemism.


Can I get power from my Belkin Express Dock HD (Thunderbolt 2) for my MacBook Pro Retina?

Question: I plug my MacBook Pro to my Belkin Express Dock HD via Thunderbolt, but I see that my battery is getting down. I was hopping to get power from the Dock. Is there any solution to this problem?
Answer: A Thunderbolt port can provide up to 10W. That's enough to charge a phone or a tablet but definitely not a notebook.
A Macbook (Air/Pro) needs  between 45 and 90W.
Answer: The MBP is not a thunderbolt device; it is a laptop with its own power source, and a thunderbolt port.
If you need to replace the power adapter for your MBP, then take care to obtain the correct wattage.


Filtering criteria for non-coding features with very low counts

Question: I am trying to do DE analysis of non-coding features of A. thaliana. I find in the miRNA and lncRNA counts file that they are abundant in zero counts, and most of the non-zero counts are very low. Now, for the DE analysis of coding features, an inbuilt filtering method to remove the extremely low counts is available in edgeR, called filterByExpr(). Is this function suitable for only those features with high counts like coding sequences, or is it suitable for non-coding features with low counts and low library sizes too?
If not, then what kind of filtering criteria should I use for filtering out genes with insignificant counts? Or should I filter out only the ones with row sums 0?
Answer: Partially answered before. I am assuming this is a lncDIFF calculation. For the lncDIFF paper it is unlikely to work as the following figure displays,
https://bmcgenomics.biomedcentral.com/articles/10.1186/s12864-019-5926-4/figures/4
However, don't take my word for this, test it. You should test the option explicitly via glmQLFTest and glmLRT. If you perform either of these tests with or without the filter the better fit (one not rejected) is the correct answer. I strongly predict the filtered data will be rejected and unfiltered data  (hopefully) will pass.
The question of what is better glmQLFTest versus glmLRT is discussed in the previous answer, here Statistical methods suitable for DE analysis of non coding RNAs
Just keep in mind this is plant data and these tests are developed for humans.


Space trajectory Optimiztion

Question: I understand that fuel mass is a major consideration of total vehicle mass and mission cost.
  Considering that earth passes Mars,I was wondering;
 If a trajectory optimization to Mars, similar to that of the moon landing's trajectory optimization of a figure 8,was initiated at some point ahead of Mars to use both the launch to Mars' trajectory velocity and the planet's(Mars')trajectory velocity together and control the decent velocity to the planet's surface from space would optimize fuel mass, over all mission cost and transit time to Mars?
Answer: The figure-8 is probably not the most efficient way to get to Mars, but it's likely how we're going to go.  As an example of a mission that didn't use it, India's MOM (Mars Orbiter Mission) spent a lot of time in earth orbit, slowly raising its orbit every time it passed perigee.  This allowed, for example, a smaller rocket engine.
There is a concept called a Mars Cycler that has some interesting applications in low-fuel missions.  The idea is you put a big spacecraft on an Earth-Mars trajectory that cycles between the two planets repeatedly.  This larger spacecraft only needs to be launched on this trajectory once, and could be used for multiple missions.  You then need to accelerate only a smaller spacecraft to rendezvous with the larger craft and eventually enter Mars orbit.  This reduces the need for large spacecraft every time a crew goes to Mars, thus reducing fuel use substantially.  Read more here.
The figure-8 itself was part of the free-return trajectory.  It minimized fuel to return if something went wrong.  Practically, all Apollo missions were on an almost-free return trajectory where only a small push would put them back onto one.  A Mars free-return is possible (check out here).  There were discussions of a private, two-person spacecraft doing a Mars free-return, which would essentially be a Mars flyby with people on board who need to come back home.
Trajectory optimization is complicated.  You will need to make sure you use both a fuel and time optimal trajectory, which are usually competing goals!  For example, there is a nearly energy-free way to get from Earth-Sun Lagrange points to Mars.  Getting to those Lagrange points is lower energy than getting to Mars.  Unfortunately, actually getting to Mars following this trajectory would take thousands of years.  Read more here.  They're really cool.  So at the end of the day, fuel-optimality is not the be-all and end-all and many more constraints are needed.  For that reason, it is highly likely that time-optimality giving spacecraft delta-V and thrust constraints is far more important than fuel-optimality, at least for crew missions.

Space trajectory Optimiztion


running a gas line to a gas heater hide do I hide the gas line

Question: I need to run a gas line to a floor mounted gas heater but I cannot run it behind the wall. How do I hide the gas line?
Answer: You might just have to box around it, if you can mount it right against the wall, fairly low.
If the line is the old black iron gas pipe, you don't have to worry about it getting crushed if something gets dropped on it. But you might have to worry about damage to the connections (and leaks) if something heavy enough is dropped on it.
If it's the yellow (or black) corrugated stainless steel pipe, you might need to be concerned about possible damage to the pipe itself, too.
But either way, your best bet might be to mount the gas line as close to the wall as possible, near but not on the floor, and build a box around it with moulding or plywood.
If it's a hose, you might be able to get away with using one of those carpet runners that you can stuff cables into on the bottom.
If you go with the build-something option, maybe you could create some built-in seating. Build a frame, put some particle board or plywood on top and throw some cushions on.
Or you could make shallow cabinets to hide the pipe and create some useful storage space.
Comment: With the right pattern carpet or tiles on the floor, it would blend right in like camouflage.  ;-)
Comment: This seems better than my suggestion of painting it like a snake
Comment: simply genius...
Answer: The simplest thing to do is to paint it the same color as whatever it is running next to.  It won't completely hide it but it will go unnoticed by some people.  Keeping it low and parallel to the floor might help too.
If you're not willing to build anything around it, then also try to take advantage of your layout and furniture to hide it.
Also consider paths where it will run in less frequented rooms or spaces.  i.e. run though a closet the out right behind the device.


Is it illegal to take turns going to the bathroom with an unrelated 3 year child in the same room if the child doesn't see anything?

Question: I just wanted to know hypothetically. Like for a babysitter or a teacher on a field trip. For instance if you went a play for a class Field trip and the child got upset at a scary part so you take the child out find a building next door to the theater where there is an office and toys and a bathroom. You both have to go so you let him go first but since there is no one else there you tell him to face the wall and he does and you do your business quickly without him seeing anything then you both leave the bathroom.
Answer: Yes, it's legal
Even if they see everything.
Sexual offences under the Crimes Act require either a sexual act or the purpose of obtaining sexual gratification. Regular use of a bathroom for urination or defecation is neither.
Comment: Also worth mentioning that a babysitter or teacher is in loco parentis.
Answer: canada
Without more, the facts you describe do not describe an offence known to Canadian law.
It is hard to prove a negative (you would have to review the entire Criminal Code), but you can review the various sexual offences (s. 150 onward), and offenses relating to public nudity, indecent acts or exposure, or voyeurism. All of these would require more than what you've described.


Grub Problem after installing Elementary OS 5.1

Question: I install Elementary Os 5.1 in HP pavilion notebook. after installing HP Notebook enter grub rescue mode and does not find "error: file '/grub/i386-pc/normal.mod' not found"
Answer: After fresh Hera install and reboot, I can't boot and get same error:

error: file '/boot/grub/i386-pc/normal.mod' not found.
  Entering rescue mode...
  grub rescue>

What I did to solve it:

Boot again with USB install stick ("Try Elementary" option).
From a terminal console, create the missing folder ( /boot/grub/i386-pc ) on the target disk.
Install grub.

Something like this:
<code>$ sudo mount /dev/sda3  /mnt    ( in my case, /dev/sda3 is my root / partition )
$ sudo mkdir  /mnt/boot/grub/i386-pc
$ sudo grub-install  --root-directory=/mnt    /dev/sda
</code>
reboot. That's all. Working.
Some info:
When installing, the wizard asked me to create an EFI partition. So, I tried WITHOUT and then WITH EFI partition. Either case, I get same error (I just keep a small partition in the first sectors of the disk, about 200MB, which I toggle from FAT32 to EFI type).
Credits to https://bbs.archlinux.org/viewtopic.php?id=207827
Good luck.
Answer: tray boot-repair-disk https://sourceforge.net/projects/boot-repair-cd/files/
or super-grub-disk


Concatenate certain rows into a cell ignoring duplicates

Question: I have a google form and I would like to sort it's responses in a separate sheet on google sheets. The results of the form look sort of like this.
Id    Job
1     Shelving, Sorting
2     Sorting
1     Cleaning, Shelving
3     Customer Service
2     Shelving, Sorting

which I would like to format into
Id    Jobs
1     Cleaning, Shelving, Sorting
2     Shelving, Sorting
3     Customer Service

Is there a formula I can use to accomplish this, noting that it ignores duplicates and groups the different ids? Ordering of the jobs does not matter.
Answer: Working example here.
The code is like:
=unique(transpose(split(join(", ",filter(B1:B10,A1:A10=1)),", ")))

where

filter(B1:B10,A1:A10=1) gives you all the B values where A = 1
join(",", filter(...)) joins the list with the ", " separator (e.g. "apple, orange" and "kiwi" becomes "apple, orange, kiwi"
split(join(...)) splits the list into an array (e.g. back to [apple, orange, kiwi]
transpose(split(...)) converts the horizontal list to vertical list
unique(transpose(...)) gives you the unique values (unique() only works with vertical list)

After this, you need to transpose then join the list
Note you must keep the separator consistent (e.g. always "," or ", ")
Comment: Works perfectly after transposing it and joining it :)
Answer: This is Apps Script code instead of a function.  To use it, you will need to use the Tools menu, and open the script editor.  Then select the function name from the drop down list, and then click the "Run" button.
To use this code, you need to have a source and a destination sheet.  You will need to change the sheet names in the code to your sheet names.  In this code, the source sheet is named 'Data'.  You will need to change that to the name of your source sheet.  In this code, the destination sheet is named 'Output', and is at the bottom of the code.  This code gets data starting in row two, and writes the output data starting in row two.  I tested it with your values and it works.
function concatCellData() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sh = ss.getSheetByName('Data');

  var colOneData = sh.getRange(2, 1, sh.getLastRow()-1, 1).getValues();
  var colTwoData = sh.getRange(2, 2, sh.getLastRow()-1, 1).getValues();

  var newData = [],
      newDataColOne = [],
      colOneValue,
      existInNewData = false,
      colB_One,
      colB_Two,
      dataPosition,
      thisValue,
      combinedArrays = [],
      arrayTemp = [];

  for (var i=0;i<colOneData.length;i+=1) {
    colOneValue = colOneData[i][0];
    dataPosition = newDataColOne.indexOf(colOneValue);
    existInNewData = dataPosition !== -1;

    if (!existInNewData) {//If it doesn't exist in the new data, just write the values
      newDataColOne.push(colOneValue);
      newData.push([colOneValue, colTwoData[i][0]]);
      continue;
    };

    colB_One = [];
    colB_Two = [];
    combinedArrays = []
    arrayTemp = [];

    colB_One = colTwoData[i][0].split(",");
    colB_Two = newData[dataPosition][1];
    colB_Two = colB_Two.split(",");

    var combinedArrays = colB_One.concat(colB_Two);

    //Get unique values
    for (var j=0;j<combinedArrays.length;j+=1) {
      thisValue = combinedArrays[j].trim();
      if (arrayTemp.indexOf(thisValue) === -1) {
        arrayTemp.push(thisValue);
      };
    };

    newData[dataPosition] = [colOneValue, arrayTemp.toString()]; //Overwrite existing data

  };

  ss.getSheetByName('Output').getRange(2, 1, newData.length, newData[0].length).setValues(newData);
};


WCF at Services faulted state

Question: I have many webservices running in my project but something odd has been happening for quite some time. My services occasionally crash for no reason with an error message "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state." This usually happens when I run the application first thing in the morning after which they occur less frequently. Any ideas as to what might be causing this error?
Comment: Hero you have descriptions about setting WCF tracing and using SvcTraceViewer to browse tracing data. Set the tracing in the service host project. Tracing: http://msdn.microsoft.com/en-us/library/ms733025.aspx SvcTraceViewer: http://msdn.microsoft.com/en-us/library/ms732023.aspx
Comment: Did you try WCF tracing?
Comment: Is this error coming from code consuming a WCF service, or from the service itself?
Comment: @Ladislav: No, not yet. I am not too sure about WCF tracing. Ne good tutorials to get me starteD?
@Graham: This is basically coming from the code consuming the WCF service
Answer: If a WCF service throws a FaultException, the client will have its state changed to CommunicationState.Faulted. If you then try to use this client object to call another service operation, you'll get the error

"The communication object,
  System.ServiceModel.Channels.ServiceChannel,
  cannot be used for communication
  because it is in the Faulted state."

You might also get this error if you try to call the Close() method on a faulted client, I can't remember.
You can check the state of your client object by checking the State property. If you want to close your client properly (which you should be doing), you need to call the Abort() method if the client is in the Faulted state, and the Close() method if the client is in any other state.
Comment: Kind of defeating the purpose of `using`, doesn't it? WCF never stops amazing me of how badly designed it is.
Answer: This sounds like a timeout combined with not handling the failing services.
It takes longer to run in the morning since code has to be JIT compiled, maybe also database needs to cache data and query plans.
Here is one way to get the WCF client to clean up after itself http://nimtug.org/blogs/damien-mcgivern/archive/2009/05/26/wcf-communicationobjectfaultedexception-quot-cannot-be-used-for-communication-because-it-is-in-the-faulted-state-quot-messagesecurityexception-quot-an-error-occurred-when-verifying-security-for-the-message-quot.aspx
Comment: but I am not using "using" blocks.
Comment: You still have to close the service after you have used it, and you need to abort the service if it is in faulted state
Comment: Indeed after removing my USING block I could see the real error. 10x

WCF at Services faulted state


How can I tell what "patch" level has been deployed to a pre-release org?

Question: I am tracking several issues with Summer '16 locker service in a pre-release org (on gs0) that are actively being discussed on this site. When Salesforce employee answers or comments with "a fix is scheduled for patch .2" or "this will be addressed with patch .5 scheduled to deploy next Tuesday" or similar comments, how can I tell what "patch" level my pre-release org is currently on? The "trust" and "Known Issues" sites that list release/patch details, do not list the gs0 pre-release instance.
Answer: At the time of this answer, you don't find out what patch they're on, at least not from a public resource. If you were a salesforce.com employee with access to the corporate network, you could access the internal network statistics pages, which is where they get their data from. All of this stuff is protected by an IP address filter, profile permissions, and so on. If you ask support nicely, they'll probably tell you, although without any public information to go on, the patch number is pretty meaningless to you directly.


Do addition and multiplication have arity?

Question: Many books classify the standard four arithmetical functions of addition, subtraction, multiplication, and division as binary (in terms of arity).  But, "sigma" and "product" notation often writes just one symbol at the front, and indexes those symbols which seemingly makes expressions like $+(2, 3, 4)=9$ meaningful.  Of course, we can't do something similar for division and subtraction, since they don't associate, but does the $+$ symbol in the above expression qualify as the same type of expression as when someone writes $2+4=6$?  Do addition and multiplication qualify as functions which don't necessarily have a fixed arity, or do they actually have a fixed arity, and thus instances of sigma and product notation should get taken as abbreviation of expressions involving binary functions?  Or is the above question merely a matter of perspective?  Do we get into any logical difficulties if we regard addition and multiplication as $n$-ary functions, or can we only avoid such difficulties if we regard addition and multiplication as binary?
Comment: It's possibly worth mentioning that addition and multiplication can both be regarded as unary operations, in which they are only capable of being the identity function, i.e. $+(n)=+(n,0)=n$ and $\times(n)=\times(n,1)=\times(n,1,1,1)=n$.  Obviously the equivalence when more $1$s are included in a product demonstrates the futility of considering $1$ to be a prime number, but what's often overlooked is that the analogy continued to addition is that $0$ is not a prime number, while $1$ is the only additive prime in the integers, and every integer has a canonical factorisation into $+(1,1,\ldots)$
Answer: Given any binary operation $(x,y) \mapsto F(x,y)$ on a set $X$ you can construct operations with "higher arity", in general in many different ways, e.g.
$g_{3,1}(x,y,z) = F(F(x,y),z)$,
$g_{3,2}(x,y,z) = F(x,F(y,z))$,
$g_{3,3}(x,y,z) = F(y,F(x,z))$,
$g_{3,4}(x,y,z) = F(x,F(y,y))$,
and so forth.  If the original binary operation is commutative and/or associative, then some of these induced operations will coincide.  In general, tracking down compatibilities between these sort of induced, higher arity operations is something that shows up a lot in category theory (and, especially, higher category theory).
So in particular you can absolutely define three-fold (and higher) subtraction operations; you'll just have more than one of them.  (Note also that in most number systems division is not a binary operation, since $a \div 0$ is not defined.)
That's the mathematics of it.  The rest of your question seems to be asking about "rules".  That depends on further context, which you have not provided.   For much of "mainstream" mathematics, the arity of an operation is not of explicit concern or interest.  If you are studying universal algebra, or model theory, or other branches of logic, or parts of computer science, it might matter, but there is no uniform set of rules.
Answer: There are no logical difficulties passing back and forth between binary associative operations and their higher-arity extensions. However, a theorem of  Sierpinski (Fund. Math., 33 (1945) 169-73) shows that higher-order operations are not needed: every finitary operation may be expressed as a composition of binary operations. The proof is especially simple for operations on a finite set $\rm\:A\:.\:$  Namely, if $\rm\:|A| = n\:$ then we may encode $\rm\:A\:$ by $\rm\:\mathbb Z/n\:,\:$ the ring of integers $\rm\:mod\ n\:,\:$ allowing us to employ Lagrange interpolation to represent any finitary operation as a finite composition of the binary operations $\rm\: +,\ *\:,\:$ and $\rm\: \delta(a,b) = 1\ if\ a=b\ else\ 0\:,\:$ namely
$$\rm f(x_1,\ldots,x_n)\ = \sum_{(a_1,\ldots,a_n)\ \in\ A^n}\ f(a_1,\ldots,a_n)\ \prod_{i\ =\ 1}^n\ \delta(x_i,a_i) $$
When $\rm\:|A|\:$ is infinite one may instead proceed by employing pairing functions $\rm\:A^2\to A\:.$
Comment: @Doug: For any unary operator $f(x)$, we may define a binary operator $g(x,y) := f(x)$.  I'll leave extending this to nullary operators as an exercise.
Comment: Thanks for not ruining the fun for us, @Ilmari!
Comment: Is the theorem every finitary operation with arity of at least 2, or does it also include unary and nullary operations?
Answer: For definiteness, let's think first-order theory of groups.  We can change the language by introducing infinitely many function symbols, one of each arity $\ge 2$.
We will then need axioms in order to move freely between products of various  arities. These axioms are quite simple, just the usual inductive definition of $n+1$-product in terms of $n$-product and $2$-product. However, we do need infinitely many such axioms.
Occam's Razor suggests that we leave well enough alone, and use arity $3$ multiplication, for example, as an informal abbreviation.
The technical difficulties become much greater if we try to produce a two-sorted theory to handle notions such as $a^n$.
I do not see any demonstrable gain to compensate for the pain of introducing operations of infinitely many arities, or of variable arities.  If we really do want what you suggest, we might as well go all the way, and do group theory within a formal set theory. Then all of the usual abbreviations can be given a formal meaning.  That is in fact close to the usual mathematical practice, except that the underlying set theory is informal.
Comment: Please note that I wrote "without having heard the term." It is possible to work within a structure without giving a name to some wider family that the structure belongs to.
Comment: I don't see a necessary connection here, why have you brought up gropus?
Comment: @Doug Spoonwood: Your post seemed to be asking about giving an associative (binary) operation multiple arities. Groups is one setting in which we do, at the informal but not the formal level. It seemed reasonable to focus attention on a single class of examples.
Comment: I don't see why you talked about groups instead of semigroups.  I guess the word "definiteness" threw me off.
Comment: @Doug Spoonwood: I actually thought a second or two about the choice. Wanted a class of structures with a familiar axiomatization. Semigroups, though from the axiomatization point of view simpler, and therefore in some sense logically prior, are in fact much less familiar. Many will graduate with a degree in mathematics without having heard the term "semigroup."
Comment: That certainly seems a strange state of affairs.  The counting numbers (1, 2, 3, ...) under addition (or multiplication) form a commutative semigroup.
Answer: I think it is usually understood as mere notation shorthand, see e.g. wikipedia article giving definition of the sigma notation in terms of expanded series. You can't get in logical difficulties if you define n-ary addition that way, because you can, at your will, either think of it as an operation in itself or a shorthand, as definition is a shorthand for what it defines.
It is not clear however from which point of view are you asking that question. Which "many books"?
Answer: Addition and multiplication have algebraic properties like commutativity, associativity, x x - +=0, etc.  Some of these properties only apply to binary operations, not operations of variable arity.  Regarding them as having variable arity would thus lead to a logical problem.  Therefore, addition and multiplication have a fixed arity of 2.
Comment: @IlmariKaronen I do not in any way denying such generalization for commutativity, and associativity.  However, do you have a way to generalize *all possible* algebraic properties?  Addition and multiplication satisfy the properties, x 0 +=x, x 1 *=x, x x - +=0, x x / =1, where x / exists, where / and - are particular unary operations.  I don't see a generlization happening here, since I don't see how you can have an identity element for a trinary operation, and the cardinality of pairs (y, z) which satisfy x y z +_3 =x, where +_3 indicates 3-ary addition, is infinite.
Comment: Actually, there are ways to generalize both commutativity and associativity to $n$-ary operators.  For commutativity, a reasonable generalization is to require that $\operatorname P(x_1,\dotsc,x_n)=\operatorname P(x_{\sigma_1},\dotsc,x_{\sigma_n})$ for any permutation $\sigma$ of $\{1,\dotsc,n\}$. For associativity, one natural generalization is given by the [$n$-ary group](http://en.wikipedia.org/wiki/N-ary_group) axioms.


Is it correct to say "I prefer to get refunded on my original account"?

Question: Is it correct to say "I prefer to get refunded on my original account" while a store asks me what refund option I would choose?
Comment: Not really relevant to the question, but it's interesting you would be given the choice. In the UK any refund is to the method/card/account used to pay initially, & *nowhere* else. It prevents fraud & money laundering.
Comment: @gonefishin'again. many UK sellers will prefer to credit store account rather than incur fees repaying to card; almost every refund I've had from Amazon.co.uk worked like that.
Comment: @PeteKirkham - I've never had anyone, including Amazon, ask me to make a choice. Of course, the last thing you ever want is 'store credit' - it means they've still got your money & there's nothing more you can do about it. I would never accept that even back in the days we wrote cheques for things ;)
Comment: My experience with Amazon UK is that I get the choice (gift card or original payment method) as in OP. Indeed I used Amazon as an example in my answer because it's so familiar.
Answer: That would not be a usual way of expressing that idea, and might confuse a fluent speaker, it would surely sound odd to many native speakers.
We do not usually speak of a person "getting refunded" but rather of a person "getting a refund".
We do not usually say "on my account" to indicate where a refund will go, but rather "into my account", or often there is an indication of which of several possible accounts will be credited.
Thus instead of:

I prefer to get refunded on my original account

one might say

I prefer to have the refund go to the account I used to make the purchase.
Please send the refund to the account I used to make the purchase.
I would like the refund put on to my Visa card ending in 1827
Please credit this card [showing the other person the card]  with the refund
Please credit my account with the store.
I want you to apply the refund to the same account I used to buy it.
I want to get the refund in cash.

Another answer suggest (indirectly):

I would prefer to be refunded in X way.

I do not think this is natural or indeed correct. A person is not refunded, money is refunded. A person gets or receives a refund.

By the way,  the form

while a store asks me what refund option I would choose?

is incorrect. You very likely  mean "when a store..." as "while" would suggest that you talked over the clerk's question.
Comment: I disagree that "getting refunded" is incorrect or even unnatural.  See these example sentences- From Cambridge dictionary: "The customer will be refunded in full up to $50,000."  From Google card (retrieved from Oxford Languages): "I'll refund you for the apples and any other damage"
Comment: You are wrong to say that I am wrong in your edit, I'm afraid. All your suggestions use 'refund' as a noun - this is fine - where it refers to the money. When used as a (transitive) verb it is the person (the one owed the money) that you 'refund', not the money.
Comment: @OJFord Yes, one can use "refund" as a verb, as in "I refunded the money to him." or "I will see that the money is refunded" or "We will refund the money to the customer."
Comment: @DavidSiegel If you find you can buy a reputable dictionary that says I'm wrong, I'll gladly refund you. ;)
Comment: "A person gets or receives a refund." - indeed, that is the process of *being refunded*.
Answer: To answer your actual question, prefer 'to be refunded' rather than 'get refunded'.
The result will be that you 'got a refund', but 'get' with the verb 'refunded' sounds odd to me.
Some other points:

'I would prefer' - if you just say 'I prefer' it sounds habitual, a general preference for all refunds in your life;

'to the original account' is better than 'on my' I think, but then you need to say something like 'I would prefer the refund be to...' too;

'when a store', not 'while', as DS said;

'a store' doesn't really 'ask' you anything, the employee does, but it's OK colloquially I suppose, particularly assuming in your real sentence it would be a specific company name ('Amazon asked me ...' sounds much more natural than 'a store asked me' to me, not that it's actually any more correct);

'which refund option' - that's routinely messed up by some native speakers, so don't worry much, but in general think 'which from a list' & 'what free-form text';

'I would like', or 'asks me to choose a refund option' - 'which I would choose' as you wrote sounds like it was a hypothetical: 'if we were to refund you which would you want'.
Comment: @DavidSiegel A person absolutely is refunded. The money is the refund (noun). ("Don't argue with the customer, just refund them.", "I only received half, please refund me the difference.", etc.)
Comment: I do not think "'I would prefer to be refunded" is natural or indeed correct. A person is not refunded, money is refunded. A person gets or receives a refund.
Comment: @OJFord Your second example is not good here, since it has "(the) difference" as the direct object.


How to use multiple navigation in sharepoint 2013?

Question:
I need to achieve above navigation system in SharePoint 2013, so I choose structural navigation, So I copied and pasted the code snippet in the master page, I achieved the first navigation successfully, I am not sure how to achieve the second navigation because it comes under page layouts. whether I need to hard code the values or any other way to achieve it by using SharePoint default navigation (Structured or managed navigation)
Answer: You can use table of contents web part in page to achieve the secondary navigation.Try these steps.
1) Go to site settings page of the site for which the navigation is required.
2) Click navigation and use managed metadata navigation for the current navigation.
3) Choose the term set(navigation items want to show)
4) Click Ok and go to the page where the secondary navigation is needed.
5) Edit page and add Table of contents out of the box web part in the page.
6) The navigation items will be displayed in the page and it is possible to align vertically and horizontally by editing in web part properties.


Does cost of an Operation matter.?

Question: I have a query which is slow when i run from SSMS and from application.I am trying to tune it.I took the execution plan and on checking I can see cost of Clustured Index Seeks on a table is 85%.That table has only two columns and one column is set as primary key.So doing Clustered Index Seek on the table is good i guess.Should i be concerned on that cost of the operation?
Comment: When asking questions about query plans, it's generally more helpful to [share the plan](https://brentozar.com/pastetheplan/). If you're looking to learn that kind of stuff about execution plans, Grant Fritchey has a [free ebook](https://download.red-gate.com/ebooks/SQL/eBOOK_SQLServerExecutionPlans_2Ed_G_Fritchey.pdf) that should help you.
Comment: okay i understand.This question of mine was a generic question whether the operation cost matter.That is the reason i didn't share the plan.
Answer: Yes and no.
Queries showing a high cost are usually a good place to start, when looking to tune a query. They are places where the query planner believed the query would spend a larger amount of its time and effort to get the query results.
However, when you've got the actual query numbers, one of the key things to check is how the estimate and the actual query run matched up. One of the first things to fix, when possible, are places where there's a big difference between the actual and the estimated numbers. For example, if the estimated and the actual rows are way off, then capturing/updating statistics for the table in question can result in significant gains.
Taking this into account, it may well be transactions that the query planner expected not to be significant, but where the estimated numbers are much smaller than the actual numbers, that are the transactions that most need tuning.
When estimated and actual numbers match well, then those high cost operations are again a good place to focus your tuning efforts. However, they shouldn't be the only thing you pay attention to.

Does cost of an Operation matter.?


image of Segre-Veronese as a tuple of polynomials

Question: This question shares the same context as  pullback of rational normal curve under Segre map, but it is otherwise independent. It relates to Exercise 2.29 in Harris (AG-first course).
So we begin with the Segre-Veronese map
\begin{align}
\phi:P^1 \times P^1 \stackrel{id \times \nu}{\rightarrow} P^1 \times P^2 \stackrel{\sigma}{\rightarrow} P^5
\end{align} given by
\begin{align}
[X_0:X_1] \times[Y_0:Y_1]\stackrel{\nu}{\mapsto} [X_0:X_1]\times[Y_0^2 : Y_0Y_1 : Y_1^2]\stackrel{\sigma}{\mapsto}[X_0 Y_0^2: X_0 Y_0 Y_1 : X_0 Y_1^2:X_1 Y_0^2: X_1 Y_0 Y_1 : X_1 Y_1^2].
\end{align} The map $\phi$ can be viewed as a map on the surface $Q$ of $P^3$ given by $Z_0 Z_3 - Z_1 Z_2=0$, which is the identification of $P^1 \times P^1$ inside $P^3$ under the segre map $P^1 \times P^1 \rightarrow P^3$.
$\phi$ is morphism of the projective variety $Q$, because its restriction to each affine open set $U_i$ is given by a $6$-tuple of polynomials. In particular, on the open set $X_0 \neq 0 = U_0 \cup U_1$, $\phi$ is given by
\begin{align}
(A): \, \phi([Z_0:Z_1:Z_2:Z_3]) = [Z_0^2:Z_0 Z_1 : Z_1^2 : Z_0 Z_2:Z_0 Z_3: Z_1 Z_3].
\end{align} Now, notice that on the line $L:=\left\{Z_0=Z_1=0\right\} \subset Q$ all of these polynomials vanish at the same time so that we can not use this $6$-tuple as a description of $\phi$, except on the open set of $Q$ given by $Q-L$.
The question now is can we find a description of $\phi$ as a $6$-tuple of homogeneous polynomials well-defined on the entire $Q$? In his Exercise 2.29, Harris claims that this is not possible if these polynomials have the same degree.
But i seem to have proved that this is not possible for any $6$-tuple of homogeneous polynomials. Here is my argument: Suppose
\begin{align}
(B): \, \phi(Z) = [F_0(Z):\cdots:F_5(Z)], \, \, \, \forall Z:=[Z_0 : Z_1 : Z_2 : Z_3] \in Q.
\end{align} Then the $6$-tuple of $(A)$ will agree with with the $6$-tuple of $(B)$ on $Q-L$ and so on every open set $(Q-L)\cap U_i$. Since the restriction of $\phi$ on $U_i$ is a morphism of an affine variety, the two $6$-tuples will agree on the entire $U_i \cap Q$ and so on the entire $Q$. But this is a contradiction since $(A)$ is not defined on the line $L$.
Question: Any comments on my reasoning above? If i am right, then $\phi$ can not be represented by a $6$-tuple of homogeneous polynomials irrespectively of their degree.
Answer: If $F_0, F_1, \ldots, F_5$ are homogeneous polynomials of varying degrees, then the notation
$$[F_0:\cdots:F_5]$$
isn't even meaningful.  The $F_i$ all have to be homogeneous of the same degree to make any sense of it.
Remember, homogeneous coordinates for points in projective space are only defined up to a scalar multiple.  Consequently, if you want to define a function from a projective space to a projective space, you need to give something where every output coordinate scales the same way when you scale the input coordinates.
Comment: Ah, that's right, i missed that. Many thanks! Any objections to my argument (assuming all $F_i$ have the same degree)?


How do you open a terminal with a specific path already cd'ed to?

Question: How do I use the terminal to open another terminal window but with a path I specify?
I am using automator to load my work stuff when I get to work, but I need to know how to do this:
Open Terminal and Type:
• cd Work/Company/Project/
• script/server
And then new tab in that terminal window and cd to the same folder.
Comment: I think this question is better suited to superuser.
Answer: This opens a new terminal window from a command prompt on Mac OSX , executes "cd /" and then keeps the window on top:
osascript -e 'tell application "terminal"' -e 'do script "cd /"' -e 'end tell'

You can put this into a script like this:
#!/bin/sh
osascript -e 'tell application "terminal"' -e "do script \"cd $1\"" -e 'end tell'

Hope this helps.
Comment: this is great! any idea on the new tab thing? I want a new tab with the same folder.
Answer: Use an applescript to do this.
e.g. Open Terminal Here
Comment: That doesn't answer his question, he wants to open a new terminal *from another terminal*.
Answer: You can write a shell script to cd to that directory
So write  a script that executes something like cd /user/music or something like that, save it as myscript.sh and run it using chmod +x myscript.sh.
This resource from the OS X developer network is pretty helpful
Comment: That's doesn't answer the question at all: He wants to open a *new* terminal window at a *specified* path. Also, you don't run scripts using `chmod`.
Comment: I could write a script to have automator execute, and chmod would make the script executable =p
Comment: But I wouldn't know how to open a new tab in the terminal window.
Answer: The two scripts below together handle the common scenarios:
1) If Terminal is already running, open a new terminal window and run the 'cd mydir' there
2) If terminal is not already running, use the initial window that Terminal spawns (window 0), rather than annoyingly launching a second window
NOTE: what's not quite perfect is if Terminal has several windows open, all of them will be brought to the front, overlapping any other apps. A solution to raising only the last terminal window to the front appears to require the black magic of AppleScriptObjC - references below:
https://apple.stackexchange.com/questions/39204/script-to-raise-a-single-window-to-the-front
http://tom.scogland.com/blog/2013/06/08/mac-raise-window-by-title/
Script 1 - open a text editor and save as:

/usr/local/bin/terminal-here.sh
#!/bin/sh
osascript `dirname $0`/terminal-here.scpt $1 > /dev/null 2> /dev/null

Script 2 - open 'AppleScript Editor', paste contents below and save as:

/usr/local/bin/terminal-here.scpt
# AppleScript to cd (change directory) to a path passed as an argument

# If Terminal.app is running, the script will open a new window and cd to the path
# If Terminal.app is NOT running, we'll use the window that Terminal opens automatically on launch

# Run script with passed arguments (if any)
on run argv
    if (count of argv) > 0 then
        # There was an argument passed so consider it to be the path
        set mypath to item 1 of argv
    else
        # Since no argument was passed, default to the home directory
        set mypath to "~"
    end if
    tell application "System Events"
        if (count (processes whose bundle identifier is "com.apple.Terminal")) is 0 then
            # Terminal isn't running so we'll make sure to run the 'cd' in Terminal's first window (0)
            tell application "/Applications/Utilities/Terminal.app"
                # Turn off echo, run the 'cd', clear screen, empty the scrollback, re-enable echo
                do script "stty -echo; cd " & (mypath as text) & ";clear; printf \"\\e[3J\"; stty echo" in window 0
                activate last window
            end tell
        else
            # Terminal is already running so we'll let it open a new window for our 'cd' command
            tell application "/Applications/Utilities/Terminal.app"
                # Turn off echo, run the 'cd', clear screen, empty the scrollback, re-enable echo
                do script "stty -echo; cd " & (mypath as text) & ";clear; printf \"\\e[3J\"; stty echo"
                activate last window
            end tell
        end if
    end tell
end run


How much voltage and amps for 2 SG90 servos?

Question: Question is pretty straight forward: How much amps and voltage do I need for 2 SG90 servos? I want to use 4 but you might already know that Arduino Uno only has 2 5V ports.
Comment: `Arduino Uno only has 2 5V ports` ... no ... the arduino has one power regulator ... the 5 V pins are both connected together
Answer: The SG90 servo datasheet is here:
SG90 Servo Datasheet
As you can see, the voltage specification is 4.8 - 6.0 Volts.  But you do NOT want to power this or any other servo via the Arduino.  Servos are quite "noisy" electrically and this can cause instabilities with your Uno.
You want to supply power to the servo directly from a +5V power supply.
I don't see the current draw for this servo specified so you will need to do your own measurements based on the loading of the output shaft.  Be aware that these draw more current with increased load on the shaft.
As far as the control signal, the Arduino Uno can certainly drive it via its PWM outputs.
Comment: These are relatively low-powered servos.  The voltage is specified, use 5 Volts.  A common 5V 1A supply will likely do well here since you are just driving two servos + your Uno.
Comment: I know that I am suppose to feed the 2 servos directly from external power source but I still don't know how much voltage and current I need.
Comment: @YağızAlpErsoy, hobby servos aren't typically specified that well. The suggestion that your measure them yourself is a good one.
Comment: @jwh20 thank you! that's it!


CSU/DSU's and DSL modems

Question: I read a few times that DSL modem isexample of CSU/DSU.
To my understanding CSU/DSU connect digital communication method to digital while DSL modulate digital communication to analog.
If so, how can it be the same device?
Comment: There are people that claim all signals are analog, and there are questions, answers, and comments of the various SE technology sites arguing that point. Digital signals mean one thing, e.g. binary `0` or `1`, then the opposite at a specific threshold (voltage, amplitude, frequency, etc.) or transition point. Digital signals are typically represented as square wave, even though they may not be nearly square. This is really a question to ask on [electronics.se].
Comment: Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you can provide and accept your own answer.
Answer: CSU/DSU is usually only used to refer to T-carrier lines, dubbed digital signal. T-carrier lines use Alternate Mark Inversion line codes. Basically, there are just two symbols - mark and space - at a high baudrate, requiring high-frequency cables.
xDSL is a family of broadband modulation schemes using discrete multi-tone modulation (DMT) or more specifically orthogonal frequency-division multiplexing. DMT uses a large number of frequency carriers to transport data. The modulation is well suited for low-frequency telephone lines in the local loop.
Re-using local-loop phone cables is much cheaper than deploying dedicated high-frequency cables. Therefore, many providers have adopted using DSL technology for their formerly expensive T-carrier business. Although the base technology has changed the complete product is still referred to with its old name. So, a CSU/DSU installation might technically be using DSL and not DS1.
When you look at a DS1 line and a DSL line on an oscilloscope, the DS1 signal looks digital (two levels) while the DSL signal looks like noise. This is often referred to as digital versus analog signaling. While there is some truth in it on the symbol level, the actual distinction is moot. Both signals are digital from a higher point of view and analog from a lower POV.
Comment: This is a really great answer.
Comment: D4(aka. SF)/AMI vs. ESF/B8ZS. AMI is very old technology, even in the era of T1's. (the only AMI I ever saw was in voice T1's) T1's were commonly signaled over the exact same physical infrastructure as POTS/ISDN. (worst case the tech would have to hunt for suitable pairs) Well before the end of the T1 era, T1's ceased to be actual T1's -- they were (and are to this day in 2021) carried via HDSL single pair circuits. (the "smartjack" turns it back into a 4-wire T1)

CSU/DSU's and DSL modems


Login without Password

Question: In Wordpress I need to add a filter where user role subscriber just put his email address in form to login, no need for password, just check if the email is for a subscriber and redirect him to a specific page, I tried many solutions but I didn't get it,
Thanks
Comment: That is asking for all sorts of abuses. You could probably write a plugin to do that but I strongly recommend against it.
Answer: WordPress core is full of surprises. You can do many things with that.
To provide a password less login to desired user role, you can modify how WordPress handles user login authentication. There is a filter named authenticate, which you can use to hook in, and extend the authorization process to enable that.
WordPress itself hook into this callback with 3 separate function -

wp_authenticate_cookie - This validates if the user is already logged-in.
wp_authenticate_username_password - This validate user_name/password combo
wp_authenticate_email_password - This validates email/password combo.

Above functions are hooked with a priority of 30.
You can hook with a function here with higher priority and check if any of these validation returns a WP_Error object. For empty password, the error code would be empty_password. If the error and error code matches, you can perform further validation to test if there is a user with that login/email, and if he is a subscriber.
Sounds Good? Here's the code -
function wpse_password_less_login_authentication( $user, $username, $password ) {
    if (! is_wp_error($user) && 'empty_password ' !== $user->get_error_code()) {
        return $user;
    }

    if (strpos($username, '@')) {
        $find_user = get_user_by( 'email', $username );
    } else {
        $find_user = get_user_by( 'login', $username );
    }

    if ( $find_user && ! is_wp_error( $find_user ) && in_array( 'subscriber', $find_user->roles, true ) ) {
        return $find_user;
    }

    return $user;
}
add_filter( 'authenticate', 'wpse_password_less_login_authentication', 40, 3 );

This function should go inside your themes functions.php (or included files) or inside an active plugin file.
Comment: It needed one small tweak and now this works for me too.
Comment: Thanks, but this code seems not working
Answer: Yes, you can add an authenticate filter to handle the email and no password case with a higher priority than the default wp_authenticate_email_password handler. e.g. (untested)
function wpse_380353_authenticate_email_no_password( $user, $email, $password ) {
    if ( is_wp_error( $user ) || ( $user instanceof WP_User ) ) {
        // Already handled by a higher-priority filter
        return $user;
    }

    if ( ! empty( $email ) && is_email( $email ) && empty( $password ) ) {
        // This is an email login with empty password
        $user = get_user_by( 'email', $email );

        if ( $user && ! is_wp_error( $user ) ) {
            // TODO: Verify that the user is someone you'd want to login without
            // a password. For now, let's reject anyone who can edit posts.
            if ( $user->has_cap( 'edit_posts' ) ) {
                $error = new WP_Error();
                // TODO: localize the error message
                $error->add( 'empty_password',
                    'Error: This user requires a password.' );
                return $error;
            }

            // We'll allow this user to login without a password.
            // Return the user object and the calling code will handle the login.
            return $user;
        }
        // else could not fetch the user by email address.
        // You'll probably now get a 'password field is empty' error
        // from a later filter.
        // TODO: If you want a different error then generate it here.
    }

    return $user;
}

// Add an authenticate filter with a higher priority (= lower number) than
// wp_authenticate_email_password which has priority 20.
add_filter( 'authenticate', 'wpse_380353_authenticate_email_no_password', 10, 3 );

Comment: Thanks, but this code seems not working,
Comment: I'd got the priority number mixed up: lower number = higher priority. Fixed. Apart from that it all works for me.
Comment: it works, thanks
Comment: Can I make a form where subscriber put his email and redirect to a specific link ? is it possible ?

Login without Password


Weight Painting/Deform in shoulders

Question: So I have been messing around a lot with the weight painting on the shoulders.
I'm still new so I don't know much about the type of weights should be on the shoulders, I've tried a lot of different weights but my model keeps deforming.
I'm content with sliding the arm forward/backwards like when you're walking, but moving it in another way like raising your hand for a high five or moving your arm back to throw a punch, the shoulder deforms and I don't know why.
Is this because of my weighting, or because of the model itself?
Comment: This is because 2 things: 1st it the position of the joint itself (see point 2): http://blender.stackexchange.com/a/34858/7777, second is twisting in the shoulder - see: http://blender.stackexchange.com/a/41550/7777. There is no twisting in the shoulder, only in the upper arm.
Comment: probable your bone has a wrong rotation center. If you could just move that rotation center in edit mode it should at least improve your rig
Answer: I'm very inexperienced when it comes to rigging, but I'll try to point you in the right direction, your rig lacks the collarbones, as scuh you expect their behaviour to be included in the shoulder.

this guys right here.
I think doing your own rig can be agreat learning experience and you can also tailor it to your own needs, I'd suggest importing the rigify rig and studying it a bit to see how it works, also looking at a few anatomical references to understand where you should insert the bones into your model.
Also skinning is very trial and error, try animating different movements and seeing how your model reacts, most high end rigs have corrective blendshapes which iron out some kinks when doing certain movements, or bulge out muscle when flexing, many ways to skin a cat.
Answer: I'm not very good with rigging characters, but no one else has posted an answer, so here's what I know:
Check the weights for the surrounding bones. The deformation looks like the upper arm bone strength is mush higher than the shoulder/torso bone strength. Blending the values between the two should help.
Answer: Try this Thread! The answer on this one helped me out a ton!!
Shoulder deformations
You divide your upper arm-bone into two, make them behave like one bone, but the upper bone of those two doesnt copy the rotation of the bottom one :) hope that helps!

Weight Painting/Deform in shoulders


What does Lor San Tekka mean when he says "Something far worse has happened to you"?

Question: In Star Wars: The Force Awakens what does the Lor San Tekka mean by saying "Far worse happened to you"?

Is it the fact that Kylo Ren has turned to the dark side?
Answer: It's relevant that the full text of the exchange is:

Ren: Look how old you've become.
Tekka: Something far worse has happened to you.
The Force Awakens (2015)

In context, Ren and Tekka are comparing how they have changed since their last meeting. Tekka is unquestionably referring to Ren falling to the Dark Side, joining the Knights of Ren, massacring Luke's other Jedi students, and generally becoming a cruel and cold-hearted person.
We can compare this to a similar exchange in the original film:

Vader: When I left you, I was but a learner; now I am the master.
Obi-Wan: Only a master of evil, Darth.
A New Hope (1977)

Here Obi-wan is denigrating Vader's fall to the Dark Side, suggesting that it has weakened him, or at least not strengthened him as much as he thinks. Ren tries to do something similar to Tekka, pointing out his age and (by implication) frailty. Tekka's response does the same as Obi-wan's, above; implying that Ren has lessened himself by falling to the Dark Side.
Answer: He was referring to Kylo Ren's transition to the dark side of the Force.

The passenger from the shuttle stared at Tekka, examining him from
head to foot much as one would a relic in a museum. Tekka gazed back
evenly. The black mask, with its slitted forehead and thick, snoutlike
breathing apparatus, covered the face of the man he knew as Kylo Ren.
Once, he had known the face behind the mask. Once, he had known the
man himself. Now, to San Tekka, only the mask was left. Metal instead
of man.
Ren spoke first, without hesitation, as if he had anticipated this
meeting for some time. "The great soldier of fortune. Captured at
last." Though emanating from a human throat, the voice that was
distorted by the mask had the sick flavor of the disembodied.
Tekka had expected no less. "Whereas something far worse has happened
to you."
Star Wars: The Force Awakens - Official Novelisation


What creatures are there that adopt and take care of children?

Question: I really want to know if there is a creature that adopts or take care of children. I tried to find one myself but it almost shows a creature that scares children or eats them which is the opposite of what I want.
Comment: Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
Answer: In mythology, there are plenty of examples, the best known are:

Romulus and Remus were nursed by the Capitoline Wolf
Enkidu, raised by unspecified beasts, becomes the friend of the hero Gilgamesh
Atalanta was raised by a she bear after her father abandoned her in a forest

In real life, we have documented cases:

Dina Sanichar, discovered among wolves in a cave in Sikandra (near Agra) in Uttar Pradesh, India in 1872, at the age of 6.
Marcos Rodríguez Pantoja (ca. 1946, Sierra Morena, Spain) lived for 12 years with wolves in the mountains of Southern Spain. He was discovered at age 19

See here for a list of documented cases of feral children. Note that the veracity for many in this list is contended.


I tried removing Ubuntu and now I can't boot into windows

Question: I am brand new to all of this. I had a dual boot system going on. Everything was going pretty well for a while and I was really enjoying everything. I was having some serious issues and there didn't seem to be an easy fix. I decided to pretty much get rid of Ubuntu. Grub didn't like that and now I can't get back into windows. I need some help!
Answer: See my answer to this:
How to boot USB from GNU GRUB 2.02~beta2-9ubuntu1?
It applies the same way except you want to be looking for your Windows partition (assuming you didn't accidentally wipe it).  Once back in Windows, you will need to change it so the bootloader won't kick into the GRUB menu every time you turn on your computer.  You should be able to find that with some google-ing.
Answer: You removed important GRUB files and kernels. I would recommend you to get a Live CD/USB, format the Ubuntu partition and reinstall it. After the installation you will be able to access Windows. If you want, you can install EasyBCD (google about it) in Windows, recover your Windows bootloader and wipe Ubuntu.


Difference between SSD firmware and SSD controller

Question: I am trying to understand the difference between these two, but I did not find a clear distinction between them.
Answer: An SSD controller is a physical chip on the SSD. The SSD firmware is the software that chip is running.
Answer: The SSD Controller is a hardware includes an embedded processor and a memory module which is DRAM and also flash chip controllers. This controller is responsible for processing the upcoming requests and taking right actions, e.g. GC if needed, packing requests and sending requests to the right channel toward the flash chips. SSD Firmware is the software implemented in embedded processor to take care of mapping logical to physical pages (FTL), garbage collection and wear-leveling algorithm.


Intuition behind Chebyshev's inequality

Question: Is there any intuition behind Chebyshev's inequality or is that only pure mathematics? What strikes me is that any random variable (whatever distribution it has) applies to that.
$$
    \Pr(|X-\mu|\geq k\sigma) \leq \frac{1}{k^2}.
  $$
Answer:
The intuition is that if $g(x) \geq h(x) ~\forall x \in \mathbb R$, then $E[g(X)] \geq E[h(X)]$ for any random variable $X$ (for which these expectations exist). This is what one would intuitively expect: since $g(X)$ is always at least as large as $h(X)$, the average value of $g(X)$ must be
  at least as large as the average value of $h(X)$.

Now apply this intuition
to the functions
$$g(x) = (x-\mu)^2 ~ \text{and}~
h(x)= \begin{cases}a^2,& |x - \mu| \geq a,\\0, & |x-\mu|< a,\end{cases}$$
where $a > 0$ and where $X$ is a random variable with finite mean $\mu$ and finite variance $\sigma^2$. This gives
$$E[(X-\mu)^2] = \sigma^2 \geq E[h(X)] = a^2P\{|X-\mu|\geq a\}.$$
Finally, set $a = k\sigma$ to get the Chebyshev inequality.

Alternatively, consider the variance $\sigma^2$as representing the moment of
  inertia of the probability mass about the center of mass (a.k.a. mean
  $\mu$). The total probability mass $M$ in the region $(-\infty, \mu-k\sigma] \cup [\mu+k\sigma, \infty)$ that is far far away from the mean $\mu$ contributes
  a total of at least $M\cdot (k\sigma)^2$ to the sum or integral
  for $\sigma^2 = E[(X-\mu)^2]$, and so, since everything else
  in that sum or integral is nonnegative, it must be that
  $$\sigma^2 \geq M\cdot (k\sigma)^2 \implies
 M = P\{|X-\mu| \geq k\sigma\} \leq \frac{1}{k^2}.$$

Note that for a given value of $k$,
 equality will hold in the Chebyshev inequality when there
are equal point masses of $\frac{1}{2k^2}$ at
$\mu \pm k\sigma$ and a point mass of $1 - \frac{1}{k^2}$ at
$\mu$. The central mass contributes nothing to the
variance/moment-of-inertia-about-center-of-mass calculation
while the far-away
masses each contribute
$\left(\frac{1}{2k^2}\right)(k\sigma)^2 = \frac{\sigma^2}{2}$
to add up to the variance $\sigma^2$
Comment: @HaroonRashid The OP was asking for the _intuition_ behind the proof, not an easy-to-understand proof.
Comment: Awesome explanation, very helpful.
Comment: I found the explanation at this [youtube link](https://www.youtube.com/watch?v=ROLsUCsWapU) easy to understand
Answer: Square integrable variables are not any random variables. They are in fact pretty regular !
Once you know that your variable has a variance, it's natural that the distance to the mean of your variable can be controlled in probability by this variance. Chebyshev's inequality is probably the simplest way to achieve that.
Answer: It's useful to view Chebyshev's inequality as more of an application of Markov's inequality which for a nonnegative random variable $X$ and $\alpha > 0$ is given by,
$$
\begin{align}
P(X \geq \alpha) \leq \frac{\text{E}(X)}{\alpha} .
\end{align}
$$
(Notice how we arrive at Chebyshev's inequality by applying Markov's inequality to the event $\{(X - \mu)^2 \geq k^2 \sigma^2 \}$ which is equivalent to $\{|X - \mu| \geq k \sigma \}$ and therefore has the same probability.)
Now the intuition behind Markov's inequality is that there is an implicit relationship between probability and expectation, and that for nonnegative random variables knowing the expected value places certain constraints on the behavior of the tail.  That is, if one already knows how large $X$ is on average, then the probability of large values must be controlled or $\text{E}(X)$ will itself be "pulled" towards a larger value.
To illustrate, suppose that $\text{E}(X) = 1$.  Is it possible that $P(X \geq 2) > 1/2$?  Obviously not, because then $\text{E}(X) > 1$ and we've contradicted ourselves.
Answer: To me it means:
The further away the random variable from the mean is, the more seldom it becomes. k gives you the number of standard deviations (if taken as a natural number) and the probabilty will automatically be limited by $1/k^2$.
My intuition why this is a meaningful statement for all random variables is the following: The measure of the whole space is limited, namely = 1. You cannot fill up the whole space in the reals with positive values (measure will be inf), so the distribution must vanish on the sides.
Answer: Find the worst case distribution, and everything else must have a lesser probability.
Since all that matters is whether a point is inside or outside the ball of radius $k \sigma$ centered on $\mu$, we should make sure all of the probability mass inside the ball is at $\mu$, and everything outside the ball is exactly on the boundary $|x - \mu| = k \sigma$; doing so would minimize their contribution to the standard deviation, thus letting us place as much mass outside of the ball as we can.
i.e. we should consider the distribution
$$ P(X = x) = \begin{cases} 1 - \rho & x = \mu
\\ \rho/2 & x = \mu \pm k \sigma
 \\ 0 & \text{otherwise} \end{cases} $$
where $\rho = P(|X-\mu| \geq k \sigma)$.
This has mean $\mu$ and standard deviation $k \sigma \sqrt{\rho}$, and thus $\rho = 1/k^2$.
(Making this rigorous would require either proving that this is the worst case. Of course, once we know what the answer should be, it may be easier to prove it more directly)
Answer: First of all, putting $\mu$'s and $\sigma$'s all over is ridiculous -- like natural units in physics, let's set $\mu=0$ and $\sigma=1$. Then Chebyshev's inequality states that:
$$P(|X|>k)\leq1/k^2$$
I.e. for a distribution to have a unit standard deviation, there is a natural limit on how much of the distribution can be some given amount $k>1$ away from the mean. This isn't particularly surprising -- as you add stuff to the distribution outside standard deviation range, you inevitably increase the standard deviation. In order to keep the standard deviation at 1, you need to squeeze the things inside the standard deviation range and reduce their deviation, so the overall deviation stays at 1.
But there's got to be a limit on how much you can reduce the total deviation, right? You can't make the contribution of the things inside to the deviation negative -- it can only go down to zero. So what exactly is this limiting case?
Well, at the limiting case, you have a Dirac delta at $X=0$ and two Dirac deltas at $X=k$ and $X=-k$. What's the maximum height of these two Dirac deltas? Answer this, and you have Chebyshev's inequality.

The standard deviation of this distribution is --
$$\sqrt{\frac{p}2(-k)^2+\frac{p}2k^2}=k\sqrt{p}$$
We set this equal to 1, and we get $p=1/k^2$ as the maximum amount of stuff you can pile at $k$ and beyond even if you use the distribution with the least possible standard deviation.
(A full proof would consider the possibility of an asymmetric distribution with a $p$ stick at $X=k$ and a $1-p$ stick at $X=-\frac{p}{1-p}k$, but it turns out the limit on $p$ is even stricter, at $p\leq\frac1{k^2+1}$.)

Intuition behind Chebyshev's inequality


CartoDB, problem with infowindows

Question: When I share my CartoDB-map, in other words,  use the link to my map, I can't get the info windows to appear. It says "there has been an error..." Why? How can i fix this?
Comment: Could you share with us the visualization for which this is happening? This error happens to appear sometimes when there's some problem with the internet connection and is just an temporal trouble, but please, let us know so we could check. Thanks!
Answer: If you're connected to the Internet behind a proxy/firewall, it's probable that the infowindow requests are being blocked. In these cases, I recommend you to access your visualization by using HTTPS instead of HTTP, which usually solves the issue.

CartoDB, problem with infowindows


Where can I find script that convert VC++ inline assembler to intrinsics?

Question: I am porting inline assembler that use SSE commands to intrinsics. It takes much work to find appropriate intrinsic for assembler instruction. Somewhere on the Internet I saw a Python script that simplifies the job, but cannot find it now.
Comment: @Hans Passant, because not simple extract inline assembler to separate assembler and then support separate x86 and x64 assembler code
Comment: Why don't you use an assembler?  You already got ml64.exe, vc/bin/x86_amd64 subdirectory.
Comment: A lot simpler than what you're looking for.
Answer: I don't think you will be happy with such a script.
First, in my opinion intrinsics are only useful for a one or two liner, if you have more instructions it is possible better to have a separate assembler file. Also with a long listing of assembler instructions you will have to control the result anyway, which include to understand each instruction and its result, which basically means you can write it again in the same time.
Second, I think you are looking for something like this because you want to port a piece of software from 32 bit to 64 bit, right? My experience told me that you will run into some strange errors because of some unexpected type casts if you don't have a look on every line of code.
Third, are you talking about Visual Studio? Is there any other compiler which supports intrinsics? We had some strange errors while porting our software using intrinsics, because there are some ugly compiler bugs while using intrinsics, mostly by messing up the stack. We had a lot of trouble in finding these things and ending up to write these functions in assembler.
So my suggestion is to be careful with intrinsics!
Comment: @Confused: That's not at all true. Intrinsics are superior to assembler for all uses- they're much more portable and more optimizable.
Comment: Yes. I'm porting a lot of 32bit inline assembler code to 64bit. I just want simplify my work, rather than solve it completely.
VC++, GCC, Intel CC and Clang support SSE intrinsics.
Comment: Visual Studio has indeed had a bad history of miscompiling intrinsics. However, these bugs are so big and obvious that they always get fixed in a followup release or patch. As of VS2010 SP1, I'm unaware of bugs in the intrinsics. But VS2010 completely miscompiled all the AVX permute instructions.
Answer: I'm not aware of a script that will do exactly what you asking. A lot of cases will also have non-SSE instructions interleaved into the assembly, and not every assembly instruction can be mapped to an intrinsic or a primitive C operation.
I suppose you can probably hack you way through it with find-and-replace. (This actually might not be that bad. How much code are you trying port? Thousands of lines?)
Also, VC++ doesn't allow inline assembly at all on 64-bit. So everything needs to be done using intrinsics or a completely separate assembly file.
I won't go far to say that using intrinsics is completely inferior to assembly (assuming you know what you're doing), but writing good intrinsic code that compiles well and runs as fast as optimized assembly is a work of art on it's own. But it maintains two advantages: portability, and ease of use (no need to manually allocate registers).
Answer: I created my own script to convert inline assembler to intrinsics. He does a lot of rough work.
https://github.com/KindDragon/Asm2Intrinsics


Using a weighted euclidean inner product to compute $d(u,v)$.

Question: If they gave us $u=(1,1)$, $v=(3,2)$, $w=(-1,0)$ and $k=5$. How do you compute $d(u,v)$? I know that $d(u,v)=\|u-v\|$ but I am lost as how to continue. Please could I get some help on this!
Answer: What is $k$ for? Also, $w$ is not in use.
Hint: Draw it in a coordinate system on squared paper (or draw the squares yourself, or just draw a draft scheme of the situation). Then find a right triangle that fits the actual problem (with parallel sides to the coordinate axes), and finally, use the Pythagorean theorem.
In the language of inner product, what you need is: $||a||^2 = \langle a,a\rangle$.


Dual-Boot vs. VM for Windows 7

Question: From reading older questions, it seems that running a second OS in a VM is the preferred way to run different instances of an OS. However, wouldn't an OS running inside a VM run slower, since the computer has to accommodate two operating systems? I want to install another instance of Windows 7 on my laptop already running Windows 7, and I am concerned that the VM instance would be slow(er), since it won't get full use of all of my memory.
Answer: If you have hardware virtualization extensions in your CPU (most server and desktop, and many laptop processors do now), CPU bound applications will have a minimal hit.
If you have enough ram to dedicate to your VM, it won't be shared (VirtualBox and microsoft's hyperv don't overcommit memory IIRC, so this is a moot point if you use one of those.  If you use VMWare, you can pin memory, so it's reserved for your VM), so memory bound applications will have a minimal hit.
Disc bound applications will always have a hit if the host & guest use the same drive, or if multiple guests use the same drive.  Often the hit is fairly significant.  If you can dedicate a drive to your VM, or use a fast NAS box for it's disc-bound applications, you'll see a minimal hit.
Does that help?
Comment: An i7 has hardware virtualization support.  But if you're unsure about a specific processor, you can look up the processor model on wikipedia.  Or google for a piece of software called CPUz, which will tell you all sorts of good stuff about your CPU.  I dimly recall dxdiag gives you some processor information, but I don't know if it will tell you whether or not you have hardware virtualization.
Comment: How can I find out if I have hardware virtualization on my CPU? My laptop has an i7 and 6MB of RAM.
Answer: Yes & No.  With the advent of Hypervisors, virtual OSes now have more direct access to physical hardware.  On the other-side of the coin... some things still have an "overhead" which will eat your performance.  For example, if you're storing the disk images in a file on the host OS, you'll still have a layer of abstraction which will eat some performance.  In many cases the amount of overhead is insignificant.  For most of the raw-computing power... there is near-0 overhead in a virtual environment (CPU/RAM access)  Many Hypervisors now also even give you a way to virtualize page-files which really can have some dramatic results.
I've actually built systems where the guest OS has direct access to a SSD, and the Host OS runs directly off a standard platter disk... and the Guest OS significantly out-performs the host-OS.
There are many advantages to virtualizing an OS... some reasons include:

portability.  You can move a virtual instance from one piece of hardware to another with minimal down-time.
scalability.  You can run multiple OSes in parallel to better utilize the hardware.  Most of the time OSes sit idle doing very little... so why dedicate 6 physical sets of hardware when you only need the computing power of 1?  What if you need an extra server to test something on without always having an extra server sitting around doing nothing?
adaptability.  If you need to switch from windows to linux to macos & back & forth... it takes much longer to shut-down one to boot into the other... than it would to simply run them in parallel.

There's several more reasons... but my honest opinion is that you run your personal favorite operating system as the Host-OS... and any secondary OSes as virtual instances on-demand.  There amount of overhead vs. processing power today makes any reasons you would dual-boot seem foolish.
Answer: You're right in that the VM'ed Windows 7 would be running with less resources (not necessarily slower, depending on your hardware). Is there a reason you want to have another Windows 7? There might be a way around it.
Also, I'm guessing you could dual boot two instances of Windows 7. However, I would recommend getting something like GRUB to manage your OS's at boot time. Windows has a nack of screwing up the boot manager.

Dual-Boot vs. VM for Windows 7


How to bake an animation with modifiers in Blender?

Question: Im making an animation in blender. The issue is that the animation can't be baked because of the modifiers. I've tried other methods like exporting it in mdd file or skrinkwrap framing but those two don't work as im animating a water mesh. I would love to hear some suggestions like blender addons that can bake all kinds of animation or other methods.
Comment: apply the modifiers and then bake?
Answer: I guess you mean it's not an armature animation, but instead a mesh generated animation?
In that case, the answer is simple: export to Alembic.
It quite literary bakes your mesh "as is" on every frame (or even subframe if you ask for it). It's the go-to format in VFX industry for pretty much everything.
Comment: I found this answer too while experimenting on stuffs. Thanks anyways.


How to calculate cash loss over time?

Question: For example, I got £100 few months ago and I didn't spend them - just kept them in my drawer at home. I understand that those £100 from few months ago is not worth same £100 but it is less today. How exactly I can calculate current money value which I kept from the past?
Answer: If inflation is at 2% per annum, in a year you would need £102 to buy equivalent goods to what you could buy today.  So if you keep your money in a drawer the buying power of your £100 in a year will be only 100/102 = 98.039% of what it is currently.
Comment: @LukasGreblikas inflation rates are statistical numbers, but what you *really* lost is the difference between the price of what you bought with the £100 when you did, and the price of that same thing when you put the £100 in the drawer. On *average* for the *whole population* this difference is the inflation rate. But for you personally it is an exact and quantifiable number, which may differ significantly from the "general" inflation statistics.
Comment: And what if I want to calculate value for few months and not for a year? Also could you help me to find United Kingdom's inflation rates?
Comment: For the 2% example, the inflation for `n` months is `(1 + 0.02)^(n/12) -1`.  You can find inflation figures here: [Retail Prices Index and Consumer Price Index](http://www3.hants.gov.uk/finance/retailpricesindexandconsumerpriceindex.htm)
Answer: While it is a true loss, as you've determined, is not a cash cost, per se.
A cash cost would be a decrease in cash holdings.  Inflation does not take your cash balance; it devalues it, so it is an accrued loss.
Central banks are extremely lazy in determining inflation, so the highest resolution available at a public level is monthly.  In the United States, there is a small project that tries to calculate daily inflation rates and seems to do a decent job, but unless if you are a customer of a particular financial institution, you will suffer a lag.  The small project refuses to make the data public in real time or even allow outside analysis.
In the UK, the Office for National Statistics is responsible for consumer inflation statistics.  The methodology is not readily available, but considering the name, it is most likely an inferior Laspeyres index instead of the optimal Fisher index as it is in the US.
To calculate the accrued cost due to inflation, simply multiply the amount of money held by the price index value at the beginning of the time held and divide by the price index value at the end of the time held.
For example, to determine the amount of value lost since March 2014, multiply the money held by the price index value for March 2014 and divide by June 2014.
Comment: Inflation in too small time periods is not an economic measure. It is affected by weather, various localized effects, seasonal changes, etc. You may see a spike in milk prices because some batch of milk was defective and there was shortage for a week, but then it goes down. That's not "inflation". If it has been a spike long enough to be noticeable for a whole month or, even more accurately, a year - then you can probably say that the prices have risen due to inflation and it is no longer a "spike" but a "climb".
Comment: @littleadv Inflation is always an economic measure regardless of time between samples.  It is only affected by changes in the quantity of money, production, and the velocity of money.  Inflation of a single product is not inflation.  Inflation is not imaginary or unnoticed until a year has passed; it always exists so long as the `|change in prices| > 0` across the time sampled.
Comment: @littleadv Your statements are not backed by any credible economic analysis.  All legitimate economists agree that the quantity theory of money is correct; the only disagreement is the ideal rate of inflation.
Comment: Your statement is wrong. Mods asked me not to engage you, so I won't. -1 for a wrong answer.
Comment: Again - you're wrong. Measuring price changes day after day is **not** a measure of inflation. You must make a measurement so that it will filter out the unrelated interference, and only sustainable price changes can be attributed to inflation. Since in your answer you were talking about price changes as a measure for inflation - claiming that daily changes are meaningful is plain wrong. You're more than welcome to continue this discussion with yourself. -1 stays.
Comment: @littleadv No credible economist has found a time limit on inflation.  No credible economist has found "unrelated interference".  Inflation has not been proven to be "sustainable".  There is no other way to measure inflation than by changes in the general price level, which is the definition of inflation.  Research is now showing that daily inflation measures are helpful.
Answer: It helps to put the numbers in terms of an asset. Say a bottle of wine costs 10 dollars, but the price rises to 20 dollars a year later. The price has risen 100%, and your dollars have lost value. Whereas your ten used to be worth 100% of the price of bottle of wine, they now are worth 50% of the risen price of a bottle of wine so they've lost around 50% of their value.
Divide the old price by the new inflated price to measure proportionally how much the old price is of the new price. 10 divided by 20 is 1/2 or .50 or 50%. You can then subtract the old price from the new in proportional terms to find how much value you've lost. 1 minus 1/2 or 1.00 minus .50 or 100% minus 50%.
Comment: The inflation rate that governments use is really just the change in price of a basket of physical goods, so it's confusing to say that my dollars went from 100 to 102 from inflation because it's really the price of physical goods in terms of dollars that's rising
Answer: There are two things you need to keep in mind when you look at Inflation as an entity.

Inflation is necessary to keep in check the value of goods. As per Moore's Law for example, a mobile phone that you buy for £100 today will be available for £50 in two years. With increased purchasing power, one needs to maintain balance between the purchasing power and its value. If you think about the 'loss' at a rate of 2% you would have £96.04 (in terms of today's value) in two years. But if you looked at the same cell phone as leverage for your business where it allowed you to do work and earn £1000 in two years - the investment would clearly offset the cost of inflation.
Inflation is incentive for people to spend their money. If you for example spent all of your £100 today, it is £100 income for someone else. He has further incentive to spend it creating a chain of transactions.

In theory while this is a true mathematical loss, the increasing purchasing power helps you leverage your financial asset to get a return on your investment.
Comment: Inflation does not "keep in check the value of goods" and has no necessity.  Technological deflation is a tiny fraction of general inflation.  Inflation erodes the rate of return on investment and depresses the valuations of investment assets.  You are correct however that inflation encourages spending in favor of investment since investment provides less marginal value.  Further, inflation decreases purchasing power.  Deflation increases it, but that doesn't matter because loans become more onerous, making depressions worse.
Comment: I admit that there must be multiple views on this. My view and opinion was based on this [TedEd video](https://www.youtube.com/watch?v=XNu5ppFZbHo#t=118)
Comment: Yes, there are, just like with global warming, but the science only has one conclusion: inflation is caused by changes in the supply of money, production, and the velocity of money.  That video until about 3:00 substantiates my comment.  It goes off the rails from there.  https://www.youtube.com/watch?v=GJ4TTNeSUdQ
Comment: This really doesn't answer the question at all.

How to calculate cash loss over time?


Blender 2.80: What is the difference between "Rendered" and "Look Dev" display modes?

Question: By pressing "Z" inside the 3D viewport in Blender 2.80 one can access the display modes of Blender. I would like to know the differences between "Rendered" and "Look Dev". Thank you.
Answer: LookDev uses the eevee renderer and some pre-selectable hdris to light your object. It ignores the lights in your scene. Rendered uses the lights in the scene, and you can change between cycles render and eevee.