Struct in C++ – incorrect reading from file

Question: My task is to create a program that does some stuff with the structures. My structure is about student's record (exam grades).
The function in the first case in my switch creates the structure and writes it into the file. The second – reads it from the file. here's my code:
#include <stdio.h>
#include <stdlib.h>

struct session {
    char name[50];
    int group;
    int exam1;
    int exam2;
    int exam3;
    int exam4;
    char test1[50];
    char test2[50];

};

void create(int);
void show(int);

int main() {

    int i, n;

    int loop = 2, num;

    while(loop > 1) {

        printf("\nChoose menu item(1-4):");
        scanf("%d", &num);

        switch (num) {
            case 1:
                printf("The number of students:\n");
                scanf("%d", &n);

                create(n);
                break;
            case 2:

                show(n);
                break;
            case 3:
                break;
            case 4:
                break;
            default:
                loop = 0;
                break;
        }
    };

    return 0;
}

void create(int n) {

    FILE *fp;
    session *year2017 = new session[n];

    fp = fopen("lab8.txt", "w");

    if(fp == NULL) {
        printf("File can't be opened\n");exit(1);
    }
        for (int i = 0; i < n; i++) {

            printf("Student #%d\n", i + 1);
            printf("Student's family name: ");
            while (getchar() != '\n');

            fgets(year2017 -> name, 50, stdin);
            printf("Group number: ");
            scanf("%d", &year2017->group);
            printf("1st exam grade: ");
            scanf("%d", &year2017->exam1);
            printf("2d exam grade: ");
            scanf("%d", &year2017->exam2);
            printf("3d exam grade: ");
            scanf("%d", &year2017->exam3);
            printf("4th exam grade: ");
            scanf("%d", &year2017->exam4);
            printf("First test (passed or not): ");

            while (getchar() != '\n');

            fgets(year2017 -> test1, 50, stdin);
            printf("Second test (passed or not): ");
            fgets(year2017 -> test2, 50, stdin);
            fwrite(year2017, sizeof(session), 1, fp);

        }

     fclose(fp);

}

void show(int n){

    FILE *fp;
    session *year2017 = new session[n];

    fp = fopen("lab8.txt", "r");

    while(fread(year2017,sizeof(session), 1, fp) != NULL) {
        printf("%s %d %d %d %d %d %s %s", year2017->name, year2017 ->
group, year2017 -> exam1, year2017 -> exam2, year2017 -> exam3,
year2017 -> exam4, year2017 -> test1, year2017 -> test2);
    }

 fclose(fp);

 }

when I compile the code the input is the following:
http://take.ms/yoo5U
so it eats't the name of the student in the second loop and also moves to the new line the grades and the second test.
I use Clion and Mac OS.
Comment: It's C++, but written in a C style using C library features. If you're writing C++ you should commit fully and switch to C++ idiom.
Comment: You need to decide which language you are using first. No one can decide for you. If you want to use C, you need to remove C++ constructs because C doesn't support them. If you want C++, you *want* to get rid of C idioms because better alternatives exist in C++.
Comment: @21koizyd guys here commented that it is not C and asked to rename it to C++ (as I use some structures that came with C++)
Comment: Your link doesn't work. Also you should delete the sessions you allocate with `new`. Right now your program leaks memory. There is also no need to allocate the array of sessions in `create` - you only use the first element of it.
Answer: In c++ is another option to write or read some data to/from file
example ( try like this ):
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void writeFile()
{
    ofstream myfile;
    myfile.open("example.txt");
    if (myfile.is_open())
    {
        myfile << "Writing this to a file.\n";
        myfile.close();
    }
    else
        std::cout << "fail" << std::endl;
}
void readFromFile()
{
    std::ifstream file("example.txt");
    std::string str;
    while (std::getline(file, str))
    {
        std::cout << str << std::endl;
    }
}

int main()
{
    writeFile();
    readFromFile();
    return 0;
}

Comment: @YuliyaChakhovich if your teacher use some funtion C++, so you can use some other features from C++ ;), I add function for readFromFile().
Comment: thank you, but C++ syntax is mostly unknown to me (as during the classes we study C), but our teacher uses some structures from C++ (or correctly, it cpp file in a C style), that's why I would like to fix the construction I use
Comment: @YuliyaChakhovich Your teacher isn't doing you any favors. For *decades* vendors pimped the idea of "moving to C++ from C at your own pace", and all it resulted in was a bunch of terrible C++ engineers that continually ran to their C homeroom. The C++ language and it's standard library are things you should embrace hook, line and sinker.
Answer: std::fgets retains the newline following the string input (assuming the buffer space was adequate to reach it). As a result, your test members and name member contain their respective strings with those newlines on their tails.
That explains your output precisely. The most immediate fix is to simply remove the newline in those strings if present, and the most opportune time to do that is after reading them. The syntax is similar to this:
char *p = strrchr(str, '\n');
if (p)
    *p = 0;

This will find the newline (which must be the last character read if space allowed) and overwrite it with a terminating nulchar.
The second problem, losing name, is because the trim code you have at the top of the loop (while (getchar() != '\n');) shouldn't be inside the loop. That is there to trim the newline after your menu selection. It belongs there (after the menu selection read); not in this loop.
All of that said, there are plenty of things worth doing differently in this code, which has many assumptions on the success of IO operations, and leaks memory like a sieve leaks rain. Embracing the standard C++ library and utilizing its many features will help with most of those, and I encourage you to do so.
Regardless, the above should fix your issue about odd output.
Comment: thanks, this fix works for new line moving, though starting from the second loop name of the student is getting lost somewhere :(
Comment: also would appreciate if you have time to give a piece of advice on how this code could be improved and done differently


Power requirement

Question: I am using Raspberry Pi 2 model B. What is the exact power requirement of this device. Some friends are saying it want 5V 2000mA power supply and some other friends are saying it want 5V 2.5A power supply. In some books I see that without peripherals it will works with 5V 400 to 700mA supply. If I connect 5V 800mA power supply to this device what is going to happen?
Answer: There is no simple answer to this question, because it depends on what you want the Pi to do.
I normally run my Pi (B, B+, Pi2, Pi3) from a Apple 1A power supply (it is one of the few I have tested which actually deliver 1A @ 5V), and they work perfectly well with a USB keyboard, mouse and HDMI display. I am sure they would run on 800mA.
When I want to run extra peripherals (such as a HD drive) I use a powered hub. When I use attached projects I use a higher rated supply.
If you want to follow up further Raspberry Pi Power Limitations contains links to various sources.
There is definitely no NEED for a 2.5A supply because the Pi2 has a 2A polyfuse, so CAN"T use more than 2A. (But it won't hurt.)
Answer: While you may be able to safely power a Pi on 700mA it is not recommended and leaves little room for expansion (e.g. adding a wifi dongle). You run the risk of undervolting the Pi, which can lead to SD card corruption and other hard to track down gremlins. There is no harm in using a higher amperage charger; the Pi will only draw the current it needs.
In short get the 2.5 or greater Amp charger and a high quality cable and avoid the needless headaches.
Comment: I detect the incipient rise of another urban myth.  The SOC and SD Card run from 3.3V supplied by an on-board regulator, so the voltage would have to be **VERY** low for the SD card to be affected. I have (deliberately) run my Pi from low voltages (from a high quality regulated source) with no ill effects.

Power requirement


Quintessential vs essential?

Question: While quintessential means 'representing the most perfect or typical example of a quality or class' [OED], it defines essential as 'absolutely necessary; extremely important'. I have noticed frequent instances of the two being used interchangeably. How did this come about?
Comment: *Essential* has more than one sense; if you read all the OED definitions it may be clearer.
Comment: Where do you see these being used interchangeably? They have quite different menaings.
Answer: I don't think they are even near to one another and even if someone comes across their cross reference it's should be considered a mistake.
All one can correlate between the two words is :-

essential > essence of something (necessary for supporting the basics/a survival support )
quintessential > essence of a thing in the purest form (for comfort/luxury/showoff etc.)

Note: Though quintessential has it roots in medival latin which points towards aether [the classic element also known as fifth element(after earth, fire, water, and air)] but to the end that too points towards achieving the purest essence, of one which heavenly bodies are composed.[reference link]
Also through the course of language and literature its meaning has kept on evolving following to current definitions along with their usage examples.

Macmillan: a feature of something that contains all of its main
  qualities a, person or thing that is a perfect example of something
  Oxford: representing the most perfect or typical example of a
  quality or class Oxford advance learning dictionary: the perfect
  example of something the most important features of something
  Collins: in such a way as to be most typically representative of
  a quality, state, etc; perfectly Cambridge dictionary: being the
  most typical example or most important part of something Merriam
  webster: constituting, serving as, or worthy of being a pattern to
  be imitated

To further narrow down the ambiguity here is a brief article on etymology of the same.
Comment: Exactly. An essential chocolate cake is one you can't get by without, even if other chocolate cakes are actually better. A quintessential chocolate cake is a perfect example of a chocolate cake, but not necessarily important or needed.
Comment: Don't entirely follow your comment, but no, using *essential* to mean 'of the very essence' is no more wrong than meaning 'necessary'; the senses are distinct but related. (probably would have been less confusing if I had said *things* rather than *definitions*; apologies for mistimed attempt at cleverness.)
Comment: @Kate: Well-stated. That was a quintessential explanation.
Comment: Since *quintessence* is merely 'the fifth essence', the connection is obvious. 'The essential difference' between two definitions does not mean it is necessary, but that it is a difference in their very substance, and could easily be replaced by *the quintessential difference*.
Comment: @Timlymington, ??. Sorry, Is it that both are replacable? Isn't using them otherwise a mistake?
Comment: @Timlymington, hope i have covered up the fifth element.
Comment: @KateGregory, that was a yum example. I'll be sure to call whoever exchanges the two a doosh.
Answer: Different borrowings, and different metaphors.
Essence is from Latin essentia 'essence, being'.
It's a present active participle of the Latin verb sum, esse, fūī, futūrus 'to be'.
Just for comparison, being is the present active participle of the English verb be, was, been.
Quintessence comes from Mediaeval alchemical Latin, for quinta essentia 'fifth essence', meaning a potion that had been distilled five times. So it probably means being that's a hundred proof or more; i.e, it's an intensifier, like very. But since essence is so immaterial, there's no real difference between the meanings. Quintessence is a learned word, but that may or may not matter.
Comment: @LawArea51Proposal-Commit: No, *proof* is not the unit but the description of the scale. It would be incorrect to say "It's a hundred Fahrenheits out there".
Comment: OED shares the common view of the etymology; "a fifth essence existing in addition to the four elements, supposed to be the substance of which the celestial bodies were composed" and hence more vital and real than the sublunary elements. But I don't suppose it matters.
Comment: @TimLymington Why is 'proof' singular in `a hundred proof or more`? Ought it NOT to be `a hundred proofS` ?
Comment: Like "percent", it is often used as a mass noun.
Comment: @TimLymington Thanks. By 'scale', do you mean that for alcohol: https://en.wikipedia.org/wiki/Alcohol_proof?
Answer: I researched this question in hopes to find an easy answer, but I came away more puzzled than when I started.
Here are the synonyms of essential suggested by my computer's on-board thesaurus (sure enough, there is quintessential, listed among the candidates), followed by the definitions provided by its dictionary:

There are two oddities, at least in my mind. First, I can't find anything in the meaning of essential that carries the essence of quintessential; second, when I looked up the other synonyms for essential in the thesaurus (i.e., when I looked up basic, inherent, fundamental, intrinsic, underlying, etc.), they all listed essential as a synonym in the reverse direction. As can be seen by the bottom part of my screenshot, though, essential is conspicuously missing from the listed synonyms of quintessential.
This leads me to believe that using quintessential in place of essential would be a mistake, as Raghav said in an answer, and Kate Gregory mentioned in a comment. Yet it's not too often that such a "mistake" would be supported by a thesaurus.
I even looked up essential and essentially in the OED, as Tim Lymington suggested, and still couldn't find any clear-cut link.
Since I was unable to find a satisfactory answer to your question, I feel compelled to upvote it; it is a quintessential etymological puzzler.
Comment: The second sense given here for 'essential' largely overlaps with the meaning of 'quintessential'; the first sense (imperative / crucial) does not. Any overlap makes the words synonyms.
Answer: Ritika,
Have a look at this:
suggesting that we don't see the words crossing each other, hence I would suggest they have not yet been replaced as yet. Besides in short, essential means indispensable, while quintessential means the most typical. And Thesaurus.com does point out quintessential as a synonym of essential, supporting what you mentioned in your original post, but I guess its like saying I always procrastinate my work then saying I always delay my work until the end.See an example here.
And both words have a different (and interesting) origin.

quintessential: derived from quintessence meaning the pure and concentrated essence of a substance. It has its story that Aristotle proposed this when he wanted to name the fifth element as quint + essence.
essential: having its origin from essence meaning: the basic, real, and invariable nature of a thing or its significant individual feature or features: Freedom is the very essence of our democracy.
Comment: How does this Ngram show that the words aren't interchangable? _Interchangable_ implies synonymous; the Ngram only tracks frequency. All this shows is that one word is less common than the other, but that can be said for [interchangable words](http://books.google.com/ngrams/graph?content=he+is+learned%2Che+is+erudite&year_start=1800&year_end=2000&corpus=15&smoothing=3&share=), too.
Comment: "Been replaced?" Essentially, your Ngram shows that _essential_ (along with its adverbial form) are more common words than _quintessential_ and _quintessentially_, and also that the word _essentially_ grew in usage from around 1700 until its peak in the latter half of the 20th century. Nothing more.
Comment: yup. just realized what i wrote! updated it thanks

Quintessential vs essential?


Orthogonal matrices with eigenvalues equally spaced over unit circle?

Question: We know that the eigenvalues of orthogonal matrices have norm 1, and thus they are all on the unit circle. However, I wonder if there is a way to construct a orthogonal matrix (with real entries) whose eigenvalue is equally spaced on unit circle (or as uniformly distributed as possible)? "A way to construct" means given an $n$, we can find such a $n \times n$ orthogonal matrix. Any help is appreciated!
Answer: The eigenvalues of the permutation matrix
$$
M = \pmatrix{0&\cdots & 0 & 0 & 1\\
1&0\\
&1&0\\
&&\ddots & \ddots\\
&&&1&0}
$$
will be all $n$th roots of unity, i.e. $e^{2 \pi i k/n}$ for $i = 0,\dots,n-1$.  These are equally spaced over the unit circle.
Answer: You could make the eigenvalues be the $n$-th roots of unity, which are "evenly spaced" around the unit circle in $\mathbb C$. For instance, the matrix $$\begin{bmatrix}1&0&0\\0&\omega&0\\0&0&\omega^2\end{bmatrix}$$ works for $n=3$ where $\omega=e^{2\pi i/3}$. I leave it to you to generalize this to arbitrary $n$.
Comment: Thanks, but sorry I forget to mention, I want the matrices to have real entries.
Comment: Ah, well then yes my answer won't work. I'll leave it up just in case people are interested.
Answer: Here is the easiest way to do it with real entries (I think). Given a real number $\theta$, the rotation matrix
$$
\begin{bmatrix}\cos \theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}
$$
has two complex eigenvalues, which have norm $1$ and argument $\pm\theta$. Using this, we can build the matrix we're after.
Take the complex unit circle, and distribute $n$ points along it so that

They are evenly spaced
The configuration is symmetric with respect to mirroring across the $x$-axis (i.e. complex conjugation)

Pair up the points in complex conjugate pairs, and for each pair, construct the corresponding rotation matrix as shown above (you can choose the sign of $\theta$ freely). Then take all those rotation matrices, and put them along the diagonal of an $n\times n$ matrix (with zeroes in all other entries).
If $n$ is odd, one of the points is $1$ (or $-1$), and doesn't have a pair mate. Just put a $1$ (or $-1$) on the diagonal of the $n\times n$ matrix instead of a rotation matrix when you get to that point.


grub rescue, unaware of ubuntu on my machine

Question: i was unaware my friend installed ubuntu on my machine until now because im suddenly getting a grub rescue error. all i did yesterday was turn the machine on, check email and turn it off. Today it wont start and im getting the grub rescue error. From what ive been able to understand so far with my limited knowledge of this situation is i need to install ubuntu on a thumbdrive since i dont have a disk, but from there i have no idea how to access it from the thumbdrive and fix this problem. I'd also like someone to confirm that files won't be lost before doing this fix attempt. (windows 7 as my main OS)
Answer: I assume you want to be able to boot both Windows 7 and Ubuntu, right?
In GRUB rescue mode, execute the following command:
ls

It will list all your drives and partitions, like:
(hd0) (hd0,msdos2) (hd0,msdos1)

If you don't know your Ubuntu boot partition, check them one by one:
ls (hd0,msdos2)/
ls (hd0,msdos1)/

When you hit the right one, you'll get a line mentioning "lost+found" an so on.
Assuming (hd0,msdos2) is the right partition, execute these commands one-by-one:
set prefix=(hd0,2)/boot/grub
set root=(hd0,2)
insmod normal
normal

Now you'll be able to boot into Ubuntu. Once you do, look for "Terminal" application & execute the following commands from the command line:
sudo update-grub
sudo grub-install /dev/sda

None of the above can damage data on your Windows partition.


Which Documentum APIs should I use?

Question: There seems to be a number of options for interfacing to Documentum; WDK, DMCL, DFC, DFS, DQL, etc.
What else is there?
When whould you use which interface? For .NET developers, for Java developers?
Answer:
WDK is for making websites.
DMCL is an old api for communicating with Documentum, in last versions it's only present as an emulation layer, so it should be avoided.
DFC is the preferred API to interact with Documentum, provides all functionality.
DFS is for using Documentum from webservices.
DQL is for querying, it's SQL-like.

DFC and WDK are Java, the others are probably usable from .Net
Comment: a link for general documentum development information: [http://www.dmdeveloper.com/]
Answer: David provides a good overview but to expand a bit...
DFC is the base Java api for interacting with Documentum.  WDK is actually built on top of DFC.  The DMCL is the legacy api built in C(or C++ I'm not 100% sure).  Prior to D6, all DFC calls used the DMCL under the covers but that layer was rewritten in java for D6 and the DMCL is there just to provide backwards compatibility at this point.
As for accessing Documentum via .NET there is a Documentum PIA that you can use to access the DFC libraries from a .Net project rather than using the traditional Java route.
Answer: You could also consider using the CMIS (Content Management Interoperability Services) interface that's being developed for Documentum. It's a web service interface that expands upon AtomPub. It won't be able to leverage all the bells and whistles of the Documentum platform, but it should allow you to use other backends like  Alfresco and SharePoint.  There's an Early Access Release available via EMC for Documentum.
Answer: Massive operation, like bulk upload, you must use DFC, because some feature are accesible only via DFC.
Web operation, I suggest the use of DFS, with is own caching system (can be a problem) and session manager.
The code is more decoupled using DFS instead using of DFC.
DFC use is deprecated, but at the moment you cannot have the same result using DFS.
There is also some technical difference: for example DFC is RMI shared object, so the object is connect to the content server. Instead DFS after web service give you the object, the object is disconnect from content server.
In DFC you have to manage Session, connection, and so many other things tipical of RMI.
DQL is only a way to make query, and so other basic operation on Documentum.
Answer: Both David and shsteimer is right.
But Documentum PIA for .Net is not encouraged now because it will be deprecated in future edition of Documentum.
Comment: Do you have a source for this information (future deprecation)?
Answer: I just found this old discussion, but based on the following link, the "EMC Documentum REST Services" is something to consider:
https://community.emc.com/community/edn/documentum/blog/2013/06/22/announcing-emc-documentum-rest-services-70

Which Documentum APIs should I use?


Taxes for selling property in foreign country

Question: I've been owning half of the house in Russia before I immigrated to the US and I recently inherited the 2nd part of it. Now I'm thinking to sell it.
Should I pay any taxes in the US if I sell it?
I'm a US citizen if it matters.
Comment: Not tax-related, but I wonder if the sanctions against Russia impact your ability to sell it.
Comment: @Barmar it doesn't impact my ability to sell. It affects only some people who are on their list. It affects my ability to move money to the USA since banks are cut off.
Answer: Yes, you'll have to report this on your US tax return and pay capital gains taxes as applicable. Note the step-up basis rules on inheritance that may increase your basis and reduce the taxable gain. Also, make sure you're aware of the requirements for FBAR, Form 8938 and Form 3520. You may also want to look into FTC (Form 1116) if you pay any local taxes on the transaction.


Trying to Add Task Due Date on Add Task button

Question: I am trying to add the Due Date(Activity Date) field to the button/action layout when a user clicks the Add button to add a Task on the Account page. I have looked all over where I thought it would be in quick action layouts and I cannot find it. Does anyone out there know if this is possible to add?
Below are pictures of where the Add button to create a new Task is on our Account page layout, as well as where I would like to add the Due Date(Activity Date) field. Any help is sincerely appreciated. Thank you so much!
Answer: This is actually done under Global Actions, then in New Task:


Film based on CC BY-SA 3.0 content

Question: If a film was based on text content under CC BY-SA 3.0 and released in theaters, would there be any way to stop people from ripping the film and uploading it to YouTube or similar content sharing sites? Also would that still be considered Piracy?
Comment: This is just hypothetical to help me understand this license more.
Comment: I doubt any commercial movie production studio would be silly enough to do such a thing.
Answer: If work is licensed under CC BY-SA 3.0 and released in theatres it would not be legal for anyone to prevent you from ripping (or using a handycam or whatever) to get the film, and then redistribute on Youtube or anywhere else.
This particular license has the clause

"The freedom to redistribute copies: Copies may be sold, swapped or
  given away for free, as part of a larger work, a collection, or
  independently. There must be no limit on the amount of information
  that can be copied. There must also not be any limit on who can copy
  the information or on where the information can be copied. "

To the extent you use this work in your own work, that is OK also -

"The freedom to distribute derivative works: In order to give everyone
  the ability to improve upon a work, the license must not limit the
  freedom to distribute a modified version (or, for physical works, a
  work somehow derived from the original), regardless of the intent and
  purpose of such modifications. However, some restrictions may be
  applied to protect these essential freedoms or the attribution of
  authors. "

If software piracy is defined as "Unauthorized copying of some purchased software. "  then there is no software piracy occurring.
Comment: would it be possible for the author of the original text to give permission to the author of the film to use a different license without changing the license of the original text?
Comment: Yes, dual licensing is not uncommon.

Film based on CC BY-SA 3.0 content


How to heal a shield guardian?

Question: The shield guardian has a creature type of "construct".  While the shield guardian is able to regenerate hit points, that may be insufficient to keep one on its feet in combat, so additional healing might be useful.  Certain types of healing, for instance, the cure wounds spell, specifically say "has no effect on constructs".  It seems logical, then, that any other method of restoring hit points, for instance, the potion of healing, that does not contain such a restriction, would be able to heal a shield guardian.  I can find no rule that contradicts this.  It seems then, that how to heal a shield guardian is to use any healing that doesn't exclude constructs.  Is this the correct interpretation of the rules?
Comment: I assume you're interested in rapid in-combat healing, or the case for constructs generically, as the shield guardian has Regeneration.
Comment: Yeah, I'm interested without regard to regeneration.  Sure, the SG can go from 1 to 142 HP in 150 seconds, but that's a long long time when the beholder is cutting loose with the disintegration all the time.
Comment: Related: [Which healing methods work on Nimblewright player characters?](https://rpg.stackexchange.com/a/156510/47185)
Comment: @RedOrca, about laying on of hands, you are right!  I must have missed that last paragraph.
Comment: You may want to add a note for clarity that you are talking about *in combat* healing only since the Shield Guardian would always be at full health outside of combat.
Comment: Edited to clarify about in-combat healing.
Answer: You are correct.
If any healing spell, item, effect, or feature does not specifically exclude constructs, and the construct lacks features that prevent healing magic from restoring its HP, then it will heal a shield guardian.
Answer: Let it take a nap.
You are correct that any healing that does not specifically exclude constructs the way cure wounds does. Turn on your aura of vitality, mash some goodberries into its face, or just tell it to take a short rest so it can spend some of its hit dice.
Comment: If you're outside of combat, the Shield Guardian is automatically at full health since it regains 10 hit points every six seconds. There is literally no circumstance where a shield guardian does not have full health at the completion of a short rest.

How to heal a shield guardian?


NMR Spectra Oddities

Question: I've noticed that as the chain length of n-alkanes increase, their number of carbon environments tend to 5 peaks, and no more, no less. Why is this? I've looked on multiple NMR (C13 NMR, I might add) databases and they show that there are 5 carbon environments. The outer carbons are all distinct environments like you'd normally expect, but the inner part of it (e.g. the innermost carbons in tridecane, C13H28) is all one environment. I hope somebody could shed some light on it. It's stumped both me and my chemistry teachers.
Answer: The environments are the same only to within the limits of the spectrometer's resolution and other experimental details; remember that every measurement comes with uncertainties, some of which are baked into the very fabric of the universe.
If you had an "infinitely precise" NMR spectrometer, all the peaks would be distinct (except when symmetry demands they be the same). In fact, every single possible compound would be uniquely identifiable by its atoms' specific shifts, shared with no others. In principle, you'd be able to assign a carbon peak at 123.6207426[...]964109454164[...] ppm to riboflavin, whereas a peak at 123.6207426[...]964109454165[...] ppm would indicate monobrominated hexabenzocoronene intercalated into a strand of DNA, and so on. Of course this is just a thought experiment and would never be possible in practice, even though it would make characterisation of complex molecules and mixtures a dream...
Comment: Specifically, to get such precise peak positions, you would need to have a lifetime of the excited state of the spin system in the order of days. I.e. a T2 of many hours. That's not a limitation of the spectometer, but of the very sample itself.
Comment: Yes, I thought that may be possible. However, is that the only reason, do you think? Would there be another reason that it works too, apart from simply the spectrometer only able to be so precise? And why 5 peaks? Why not four, or six? Do you know why the number of peaks doesn't keep on increasing even after, say, dozens and dozens in the carbon chain? Thank you for the comment; it really helped. I'm just wondering if that's the only explanation for it.
Comment: I'm afraid that trying to quantify at what point the signals will start to overlap is probably quite hard from theoretical considerations alone. It makes sense for it to happen though; the further apart things are, the weaker they interact with each other. You might find it interesting to check the 13C NMR of a sequence of 1-functionalized alkanes, e.g. 1-hexanol, 1-heptanol, 1-octanol, 1-nonanol, 1-decanol, .... See, for example, [here](https://books.google.com.au/books?id=YJxVvEsr6YoC&lpg=PA140&ots=uXfAxJr1Tx&dq=octanol%2013%20NMR&pg=PA140#v=onepage&q=octanol%2013%20NMR&f=false).
Answer: There is a very simple anwer: these methylene groups are practically chemically equivalent. It is impossible to make a specific reaction with one of them.
Chemically equivalent hydrogens have the same chemical shift, and that's it.
Additionally, when two protons with similar CS couple, they create a higher order spectrum instead of two doubletts. The closer the CS are, the more the outer peaks get suppressed and the inner coalesce. Classic transition from AB to AA', the roof effect becomes so pronounced that you only see one peak, perhaps with a funny shape.
With 13C+decoupling, you seem to be slightly better off because there are no interactions (line splitting) visible. Still each line has an intrinsic bandwidth, because the relaxation times are finite, and the magnetic field has a finite homogenity. And the temperature distribution over the sample has a finite homogenity. Etc.
And of course you have in fact still interaction with surrounding protons, only they cancel out in the spectrum. Doesn't mean they're not there. Because otherwise you'd get relaxation times in the order of days with decoupling, which is not the case.

NMR Spectra Oddities


How/where is Minecraft lighting handled?

Question: How/where is lighting handled with a vanilla Minecraft server and client? My current understanding of lighting is that the server would store the block's light in the block data, then send this to the client for rendering. Is this correct?
Comment: I don't know what kind of answer you will get here for this.  I have the same understanding though I don't know the answer for sure.  Do you have discord?
Comment: @IronAnvil unfortunately I don't have discord. I will try reading through the code to see if I am right, however I might not get the answer for a while.
Answer: Yes, it's server-side and also saved to file. It has to be server-side, because it determines where mobs spawn, crops grow, etc.
That's also why lighting bugs often persist relogging and only get fixed when placing/removing/blocking/unblocking a light source.
Sunlight is saved in two-dimensional matrices that include the height of highest opaque block in every column. Block light is stored per block. The total light gets calculated from both sources at runtime. Nothing is saved in the block data, because that would require every block to be a block entity, which would be very laggy. Instead it's a separate system.
The client then uses these light levels, together with their source (block or sun), the time of day (evening is more red than noon) and your brightness setting to determine which colour and brightness to apply when rendering the blocks and entities.
(wiki page about light, archive)
Comment: Myrean Eario has a video that abuses lighting updates to generate server lag so that he can show something in slow-motion without having low FPS. Yes, it will probably save a little bit of client lag, but much more on the server.
Comment: This was pretty close to what I was thinking it was. Does this mean that if I changed a block (using bukkit) like redstone repeaters to not emit light server side, it would remove client side lag? (From BLUs)
Comment: Update for 1.14: The lighting system was changed a lot. I don't know how much of this answer still applies.


Toilet flange issue. Any hope?

Question: The last plumber suggested glue-ing (caulking) the toilet to the floor without any bolts. Is that the best solution for this ? Attaching the photo. The old flange does not gap to fit in the screws / bolts.
My experience level is 1/10 :)
Thank you for reading !
Answer: I would get a repair flange (screws to the old one) then fire your plumber because he should know how to install this 10$ repair kit. Added there are compression flanges closer to 40$ that will also work but I would choose the <10$ option.
Comment: The repair flange is a thin steel ring and can be used in most cases with just a few screws to hold it in place, the compression flange fits down inside the pipe and I usually cut the old one out and after installing the new one back fill with hydraulic cement but have General Contractor friends that say this is a waste of time but some still do it.
Comment: Thanks Ed :) This is helpful. I am now thinking maybe I can try save the $150+ and do it myself.

 Do I have to remove the old flange ?
 Is there enough space (from photo) to slide in the repair flange ?
 Will a repair flange or a compression flange not increase the height and go higher than the tiles ?

Toilet flange issue. Any hope?


Etymology of "static" functions

Question: I get why static local variables are called "static" -- we want them to be allocated in static memory! But what is the reason for calling functions and variables we want restricted to the current file "static"? I don't see the connection; either way, they're allocated in static memory, right?
Comment: "we want them to be allocated in static memory" any expectation/assumption regarding where a variable is actually stored should not drive how you write your code.  Keywords are at best a suggestion in this area.  Register in C is a good example.  Just because you declare a variable "register" does not mean it will be stored there.  It could be there aren't enough registers or the compiler could just ignore it.
Comment: The short answer is: it is a real mess. Many different languages use `static` to mean many different things, and many of those languages have inconsistent meanings even within the language. In most cases there's some way to say "the characteristics of this thing are determined through a *static analysis* of the code" -- that is, some characteristic is determined by the compiler at compile time. Like, the address of a static variable is determined by the compiler, unlike the address of a heap or stack allocation.
Comment: What is "static memory"? Do you mean the BSS and DATA segments of a ELF file?
Comment: @EricLippert This is what I was looking for. Please post as an answer. Also: how does the "static analysis" interpretation apply to the "storage duration" meaning of static?
Comment: Because you can statically determine the lifetime of the storage. Unlike a local variable, whose lifetime depends on the duration of the call or the lifetime of its enclosing closure.
Comment: @EricLippert and that duration would just be "forever" right?
Answer: The static keyword is overloaded with multiple meanings, and which meaning applies depends on where it appears.  It affects both the storage duration (lifetime) of an object and the linkage of the identifier associated with an object of function declared at file scope.
Refer to "6.2.2 Linkages of Identifiers" and "6.2.4 Storage Duration of Objects" in the online draft of the C11 standard for details.
Note that the static keyword only affects linkage for function and object identifiers declared at file scope (outside the body of any function) - identifiers declared within a function or block (and without the extern keyword) have no linkage.
Answer:
I get why static local variables are called "static" -- we want them to be allocated in static memory

Um, no. The static keyword dates back to the early days of the C programming language, where it can both specify the scope and lifetime of the item.
Languages "inspired" by C have copied the static keyword and used it with its "lifetime" meaning: static members typically have a lifetime of the entire execution of the application.
Answer: In C, and depending on use, the static and extern keywords denote either the scope or the lifetime of a variable
IMHO, this was (and continues to be) a mistake.  It seems illogical that use of static on a variable at file-scope has a different meaning than when used on a function-scope variable.
At least C++ has addressed this, by using public and private for scope, while retaining static for lifetime.

Etymology of "static" functions


Has anyone used a SpokePOV in the rain?

Question: Will they survive wet weather?
Answer: There's a discussion about waterproofing etc here, in the SpokePOV Forum on ladyada's site.
Answer: Here is someones feedback from when they were using it:
http://forums.adafruit.com/viewtopic.php?f=17&t=12283
"The contacts and components will corrode. You will need to waterproof it."
Answer: I Would assume you would have to seal a 4 clear plastic wheels onto your tires with click ties and silicone or just hot glue (I do not know if it would hold on very well to the metal however)
Answer: There are a few different answers for different variations on this question.
Q: Will they survive a rain shower if they're outside and off while I'm inside at school or work?
A: Sure! Nothing on the PCB isn't waterproof, with the exception (possibly) of the switch, and switches which are sealed are available. Make sure the battery cases don't hold water.  It would probably be best to replace the switch with a jumper in this case.
Q: Will they survive a hit from passing a sprinkler while powered on? What about saltwater, which is conductive?
A: This probably won't cause lasting electrical damage.  I doubt that they'll continue to work while this is happening, but the low voltages everywhere mean that nothing is going to be arcing too badly.
Q: I like to ride on the beach, sometimes in the ocean.  I do it every day.  My bike frame crumbles in my hands, but I'm OK with it.  Will my SpokePOV be damaged by this use?
A: Um, yes.  Components on the PCB will corrode, like other metal objects, when exposed to water. If this is the case, or you'll be riding in the rain often, consider applying a clear conformal coating to your board.  They're available both as aerosol sprays and in pens.  Make sure that you pick a clear one, or your LEDs will be dim!  You might also test a polyurethane clear coat, typically used in wood finishing, if you don't want to order conformal coat.

Has anyone used a SpokePOV in the rain?


How does $\bar{r}\times(\bar{\nabla}\times) - \bar{\nabla}\times(\bar{r}\times)$ relate to the orbital angular momentum operator?

Question: When I attempted to calculate the following by hand $$\bar{r}\times(\bar{\nabla}\times\bar{F}) - \bar{\nabla}\times(\bar{r}\times\bar{F}),$$ I noticed some of the terms I extracted looked similar to the terms that appear in the oribtal anglar momentum operator $$\bar{L} = -i\hbar(\bar{r}\times\bar{\nabla}).$$ Is there a condensed expression that uses $\bar{L}$? How does $$\bar{r}\times(\bar{\nabla}\times) - \bar{\nabla}\times(\bar{r}\times)$$ relate to the orbital angular momentum operator?
Comment: I added more parentheses. Did that improve clarity?
Comment: No: $\vec a \times ( \vec b \times \vec c) \neq (\vec a \times  \vec b) \times \vec c$...
Comment: @pressure Did that fix the parentheses issue?
Comment: Yes, it did fix it.
Comment: @pressure I finally was able to answer the following question: http://physics.stackexchange.com/questions/103664/dipole-transformation-of-maxwells-equations Please investigate this question, because there is a fourth component in the field.
Answer: In Einstein summation notation, we'd write
$$\vec U = \vec r \times(\nabla\times\vec F) - \nabla\times(\vec r\times\vec F),$$
using a Levi-Civita symbol $\epsilon_{ijk}$ as:
$$ U_a = \epsilon_{abc} ~r_b ~\epsilon_{cde} ~\partial_d ~F_e - \epsilon_{abc} ~\partial_b ~\epsilon_{cde} ~r_d ~F_e.$$Since $\epsilon$ is not varying with space we can commute it with $\partial_b$ on the right, leading to
$$ U_a = \epsilon_{abc}~\epsilon_{cde}\left( r_b  ~\partial_d ~F_e - \delta_{bd} F_e - r_d ~\partial_b ~ F_e\right),$$ and furthermore we have the "BAC-CAB" rule that $\epsilon_{abc}\epsilon_{cde}$ can only be nonzero when either $a = d$ and $b = e$ (with coefficient +1) or when $a = e$ and $b = d$ (with coefficient -1), so it can be rewritten as $\delta_{ad}\delta_{be} - \delta_{ae}\delta_{bd}.$ So then this expression is
$$ U_a = (\delta_{ad}\delta_{be} - \delta_{ae}\delta_{bd}) \left(r_b ~\partial_d ~F_e - \delta_{bd} F_e - r_d ~\partial_b ~ F_e\right),$$whence the term $\delta_{bd} F_e$ will always vanish, as we get $\delta_{ae} F_e - \delta_{ae} F_e = 0.$ Similarly the other terms suffer from $\delta_{bd}$ forming $r_b \partial_b F_a - r_b \partial_b F_a = 0.$ So the only term left is the $\delta_{ad}\delta_{be}$ one, leading to $$U_a = r_b ~\partial_a ~F_b - r_a ~\partial_b ~ F_b.$$The first term can be rewritten as $\partial_a(r_b F_b) - F_a,$ so this can be written as,$$\vec U = \nabla(\vec r\cdot \vec F) - \vec r (\nabla \cdot \vec F) - \vec F.$$
This looks a little like a BAC-CAB rule too but it cannot be of the form $A \times (B \times C)$ because the $\nabla$ would probably not be acting on $F$, so let's instead target $(A \times B) \times C = B (A \cdot C) - A (B\cdot C)$ with $A = r$, $B = \nabla$.
In other words, let's calculate $$\vec V = (\vec r \times \nabla) \times F,$$ which we do the same way but with $$V_a = \epsilon_{abc} \epsilon_{bde} r_d \partial_e F_c.$$The relevant $\epsilon \propto \delta\delta$ analysis yields:$$V_a = (\delta_{ae} \delta_{cd} - \delta_{ad} \delta_{ce}) r_d \partial_e F_c = r_c \partial_a F_c - r_a \partial_c F_c = U_a.$$
In other words, $$\Big[\big(\vec r \times\big),~ \big(\nabla \times\big)\Big] = \frac{i}{\hbar} \big(\hat L \times\big).$$


Out of breath after swimming 300m

Question: I swim combat side stroke only, and have managed to make my way to around 300m straight. However, it seems like no matter what I do, I can't make it past 300m. Yesterday, I put a float between my thighs and did minimal flutter kicks instead of the big scissor kick in the css stroke, and felt like a could swim forever. Why am I running out of breath with the scissor kick? Is it because I'm trying to hard to propel with my legs, or is it because I'm trying to hard to balance myself? I'm a little confused.
Answer: Basically the difficulties you're having in swimming comes from core muscular fatigue. You use a lot of abdominal and back muscles while swimming (a lot of little stabilizing muscles) in order to keep proper body position--horizontal with your hips at the surface. As you get tired, your hips sink and you end up causing more drag, which in turn makes it even harder to move efficiently. A pull buoy takes care of a lot of this support. So although you'd be putting more strain on your shoulders and lats to pull through the water, you've now taken some of the burden of staying afloat away from your core.
Furthermore, with small flutter kicks, you are going to be creating less drag than with big scissor kicks (keeping a lower horizontal profile). That may contribute. Additionally--and this may be a bit of a reach--a scissor kick is more of a power exercise, while a flutter kick is more aerobic. Think about it like doing a lot of body-weight squats over and over versus jogging. It taxes your legs more thus requiring more oxygen to support the work.
To improve your distance, I would suggest doing interval training--or at least repetition training--rather than long, slow distance. For example, instead of doing a 300 straight, do 3 x 100. Rest a little between each and try to keep the intensity a little higher. Eventually make it 4 x 100, and so on. Similar to track, swimming is generally trained as an interval workout, not a "til-failure" workout.
Answer: This guy explains the long answer way better than I can say it.  Jump to page three for your specific situation.
http://adventure.howstuffworks.com/outdoor-activities/triathlons/training/train-with-pull-buoy.htm
The short answer is the pull buoy is holding you up, but really all your questions come into play.  You run out of breath without a pull buoy because kicking is hard work.   The buoy saves you the energy you've been using to kick.  It holds your bottom half up in the water without your input (even though those buoys seem so small).  You also are more hydrodynamic with a pull buoy because your legs aren't moving.  The buoy helps you keep a straight form.  A lot of swimmers don't have that powerful a kick so what you are experiencing is totally normal.
Answer: Sidestroke can be energy intensive because of the effort required to keep your head and shoulder above water, although the CSS tries to mitigate this. Sidekick creates a lot of drag, basically making the stroke a stop-start affair. If too much of your body is above the water, you are effectively treading water and swimming at the same time. Have you tried freestyle?

Out of breath after swimming 300m


Has there been an attempt to reduce set theory to logic?

Question: I am looking for papers and books that try to reduce set theory to logic. I know there have been attempts to reduce arithmetic to logic, but I am looking for texts that, by logic alone, prove some of the basic axioms of set theory, like the existence of the empty set, the existence of the unordered pair of two sets, the existence of the union of a set of sets, the existence of the powerset of a set, etc. Has there even been such an attempt to ground set theory in logic, perhaps not first-order logic, but second-order or higher-order logic?
Comment: How do you distinguish between "reduce set theory to logic" and "define logic so broadly that it includes set theory"?
Comment: Apart from PM specifically, I'd suggest looking more generally at *logicism* in the philosophy of mathematics.
Answer: The magic words are "Principia Mathematica" by Whitehead and Russell (as opposed to the one by I. Newton)
Comment: Link to specific SEP's entry: [Principia Mathematica](https://plato.stanford.edu/entries/principia-mathematica/).
Answer: I may well be misinterpreting your question, but it sounds like you're asking if the axioms of set theory can be reduced to pure logic ... to which the answer is no: these axioms are not logical truths. There is no way to derive any of these axioms from purely logical axioms.
We use axioms of set theory in order to formalize and 'make hard' certain intuitive conceptions we have about sets. You could say the axioms describe a world of sets. And yes, we can use the language of logic to do this.  But note, this language includes symbols that are not purely logical symbols, such as $\in$. And while the axioms including those symbols describe 'truths' about set theory as we see them, as far as pure logic is concerned there could be a completely different interpretation of the $\in$ predicate that doesn't work at all like we imagine $\in$ to work, and in which the axioms of set theory end up being false.


If a probability density function (pdf) has bounded derivative, is the pdf itself bounded?

Question: Suppose a probability density function (pdf) $f$ is differentiable almost everywhere and continuous and has a bounded derivative.  Is the pdf itself bounded?
Answer: Your conjecture appears to be true, and I think I have succeeded in proving it below.  To prove this, we can give the proposal a definite statement for a real-valued random variable, and prove the result in this simple context.  (It should be simple to extend this to multivariate cases.)  The proof first shows that if the density is unbounded then it must have an infinite limit at an internal point of the domain.  If the derivative is bounded almost everywhere then the density cannot change much within a neighbourhood of this point and so it must be infinite within this neighbourhood, which would lead to an infinite integral for the density.

Theorem: Consider a density function $f: \mathbb{R} \rightarrow \mathbb{R}_+$.  If $f'$ exists and is bounded almost everywhere on the domain, then $f$ is bounded.

Proof: We will use a proof-by-contradiction.  Suppose ---contrary to the theorem--- that all the antecedent conditions of the theorem hold, but $f$ is unbounded.  Since $f$ is a density function it is bounded from below by $f \geqslant 0$, so it must be unbounded from above.  Moreover, since $f$ is a density function, it approaches zero in its left and right tails, so it must approach infinity at an internal point, from either the left or the right (or both).  Without loss of generality, we will suppose that the function approaches infinity from the left, so we have:
  $$\lim_{x \uparrow a} f(x) = \infty \quad \quad \quad \text{for some } a \in \mathbb{R}.$$
Since the codomain of $f$ is the set of real numbers we have $f(a) \neq \infty$, so this is a point where the function approaches infinity, but is not equal to infinity, so $f$ is not continuous at $a$.  Since $f$ is not continuous at $a$ it follows that $f'$ does not exist at $a$.  Since $f'$ exists and is bounded almost everywhere on the domain, but it does not exist at $a$, this means that it must exist and be bounded on the interval $[a-\epsilon, a)$ for some $0<\epsilon<\infty$.  Let $0<U<\infty$ be the upper bound of the derivative on this interval.  Then for all $0 < \varepsilon < \epsilon$ we can apply the fundamental theorem of calculus to get:
  $$\lim_{x \uparrow a} f(x) - f(a-\varepsilon) = \lim_{x \uparrow a} \int \limits_{a-\varepsilon}^x f'(r) dr \leqslant \lim_{x \uparrow a} U \cdot (x - (a-\varepsilon)) = U \cdot \varepsilon.$$
For all $0 < \varepsilon < \epsilon$ we can rearrange this inequality to obtain:
  $$f(a-\varepsilon) \geqslant \lim_{x \uparrow a} f(x) - U \cdot \varepsilon = \infty - \text{finite} = \infty.$$
This means that we must have $f(a-\varepsilon) = \infty$ for all $0 < \varepsilon < \epsilon$.  This contradicts the stated codomain of the function, and it also means that:
  $$\int \limits_{a-\epsilon}^a f(r) dr = \infty,$$
  which contradicts the fact that the probability density must integrate to one.  This proves the theorem.  $\blacksquare$


Current Fiscal Year in apex

Question: I need to check if close date of opportunity is equal to current fiscal year in apex.Can someone explain me how to use get current fiscal year.FYI my Org doesn't have custom Fiscal year setup.(Its Standard Fiscal year).
Answer: I like this approach better, because it will work in whichever fiscal year setup you're in. It makes use of an SFDC table that is not very well known:
String currentFiscalYear = [SELECT FiscalYearSettings.Name FROM Period WHERE Type = 'Year' AND StartDate <= TODAY AND EndDate >= TODAY].FiscalYearSettings.Name;

Comment: I also prefer this method for the OP's use case, but it's risky for determining fiscal quarters/years of a *generic* date. The Period object is populated automagically by SF via what seems to be an internal, system-wide trigger on all objects. Anytime a record is created (*excluding* those made in unit tests) containing a date field with a value set to a year not represented by any Period records then new, corresponding Period records are generated. Thus, if the filter in the SOQL query above were tied to a generic date with a year not represented by any Period records you could have problems.
Comment: The cool thing about this query is you can easily determine which fiscal period you're in as well, and the year of the fiscal period:

Select Type, StartDate, EndDate, Number, FiscalYearSettings.PeriodId,
 From Period
Where Type='Quarter' and startDate <= TODAY and endDate >= TODAY
Comment: How do you substitute Today with a date if one is looking for future Fiscal year, unless one formats the date [YYYY,MM,DD]. Any ideas?
Comment: Hi Mubeen. Probably better chance of success if you ask a new question on salesforce stackexchange for this. That way we can get the question clear and have more people look at it.
Answer: You can get the month of your organisation fiscal year with this query :
Integer orgFiscalMonth = [SELECT FiscalYearStartMonth FROM Organization].FiscalYearStartMonth;

And create a Date variable using this :
Date orgFiscalYear = Date.newinstance(system.today().year(), orgFiscalMonth, 1);

Current Fiscal Year in apex


Google page: fancy letters

Question: I used to see a fancy google page with various modifications of image-like letters but
now I see an ordinary google page WHY? On what this depends? :
Answer: That is the Google Doodle!
And what it depends on is what Google decide to amuse us with on their search page at any time, usually to commemorate a historical event whose anniversary it is.
They do seem to be less common now. They were daily for some time, but I haven't seen one for a while either.
Comment: That's quite a good explanation ... thank you.

Google page: fancy letters


I can't get my car into first or second gear without lifting the reverse trigger on the gear shift knob, is it safe to drive?

Question: My car is a 2010 vauhall Astra, if I try to get into first or second gear it feels like there's something physical blocking me. When I lift up the trigger on the gear stick, that you usually use to get into reverse, I can get into first and second but I can't find any way to get it into reverse. I have booked it into a garage on Friday, is it unsafe to drive until then?
Comment: Is this only while running, or do you feel the same behavior when the vehicle is off? Could be a weird symptom of clutch dragging
Answer: I wouldn't expect there to be any safety issues, as long as you can shift safely when holding the trigger that is. Mechanically the worst case is your car stops shifting while you are on the road and you have to pull over, which is usually more a question of inconvenience.
If you get lots of grinding of gears or slipping I'd recommend you don't drive it as you could be damaging the gears and/or clutch, you're better off getting a tow.


SWTOR: Refer a Friend

Question: In the Star Wars the Old Republic MMO, can two new subscribers "refer" each other so they both get the referral rewards?
Answer: From the game's official site:
As an active Subscriber, you have a personal referral link to send to your friends!

Refer friends who have never had a SWTOR account.
Invite previous Subscribers who have been unsubscribed for 90 days or more.
Tell your friends to use the link as the first step in creating a new account or logging back in to an existing account. By clicking through the link to create an account or log in, they will be registered as your "Referral."

So, if both of you have active accounts, you can give a referral link to each other. Then you can both create a new account or both use another, expired account that is older than 90 days, and reap those benefits for your active accounts. Easy!
There may even be a possibility (if the developers have looked over this exploit) to save two of your referral links, wait for 90 days for your active accounts to expire, and give them a boost with your referral links. Efficient!

SWTOR: Refer a Friend


Do daleks have gender?

Question: Having a robotic voice and being another species, the Daleks live in a robotic shell, and their names give away nothing. So I am curious: is there ever any mention of a Dalek having gender?
Comment: Can I say how glad I am that you didn't phrase that as "Do Daleks have sex?"?
Comment: Oswin Oswald was turned into a Dalek and the Dalek still thought of itself as female. That's the closest on screen to a female Dalek I can think of. Genesis of the Daleks showed female Thals fighting Kaleds but there weren't any female Kaleds flghting.
Comment: Daleks don't have gender, although there's some mention of the Kaleds (the humanoids who ended up in the Dalek shells) having men/women in some of the Big Finish audio stuff.
Comment: @SeanDuggan... what you dont want the image of two monoccular squid creatures having the tenticles twisted together in the sweer embrace of coitus stuck in your head?
Answer: Daleks as we know them now do not have a gender, they don't even reproduce like normal gender based races... Originally they were humanoid in nature so they most likely had a gender previous to their transformations into Daleks.
http://en.wikipedia.org/wiki/Kaled#Origins

The Doctor first encountered the Daleks in the second serial of the
  show, The Daleks (1963). In this version of Dalek history, the Dalek
  home-world Skaro was once home to two humanoid races: the peaceful and
  scientifically advanced Kaleds/Dals (who were described as
  philosophers and teachers) and the warlike Thals. Following a short
  but terrible nuclear war between the races, the Dals were mutated and
  became the insane and xenophobic Daleks.

In fact they are pretty much cyborgs in general, though their biological bodies are within the shells.
http://tardis.wikia.com/wiki/Dalek

Although the Daleks looked entirely robotic, they were in fact
  cybernetic organisms (or cyborgs), with a biological body encased in
  and supported by a protective outer shell of Dalekanium metal armour,
  armed and mobile.
In this respect, they were somewhat similar to a Cyberman; unlike
  them, however, the Daleks' bodies had mutated so drastically from
  their Kaled ancestors they had lost all humanoid appearance, save for
  one eye.
Comment: Daleks are completely organic beings, in a tank. They are not cyborgs.
Comment: Cde a cyborg is a being that has both organic and mechanical parts.  The Daleks require the tanks to survive, in fact I believe in some parts of the series you see / hear what happens when their tanks fail or the being inside is attempted to be removed.  One example is Into The Dalek in which the medical staff tell the Doctor that they attempted to open up the malfunctioning one they realized it had a living being inside.  The parallels drawn in that particular episode show that the tank is more than just a tank, the Dalek needs the mechanical portions.
Comment: does an iron lung, or an IV make a person a cyborg? What about a space suit? A life support system does not make an organic being a cyborg. Remember the Dalek nine wanted to kill, the crazy Dalek that betrayed darvos, The one that became a mutant.
Comment: You mean Dalek Caan, he was in the shell of the tank.  You are talking about stuff that doesn't make cyborgs but we saw the inner workings of the tank during Into the Dalek.  The tanks modified the Daleks as seen in the episode, the part where they find the secondary brain that was stoked the fire within the Daleks to destroy everything and "keep them pure".
Comment: If humans evolved to the point where the only thing left was our brain and our brains were put inside of a mechanical being to survive would you not consider us to be some form of cyborgs then?
Comment: In Remembrance of the Daleks, the Doctor, Ace, Rachel and Allison look over a destroyed Imperial Dalek (that is, those associated with Davros) and Rachel comments "The other Dalek [Renegade faction] was underdeveloped, with vestigial limbs and sensory organs, almost amoeboid. This is altogether different, it has functional appendages with some kind of mechanical prosthesis grafted on to its body"
Answer: Daleks do not have gender, I believe, because when they are made, all emotion is sucked away except hate (according to the doctor in the episode Dalek). I am guessing that with all emotion gone, gender and creativity is absent as well. The closest thing I know of with the limited episodes I have watched is that group of Daleks (I forgot what they call themselves) who "even dared to have names." I have only seen up to season two though, so my information may not be entirely accurate.
Comment: The group of Daleks with names you're thinking of is the [Cult of Skaro](http://tardis.wikia.com/wiki/Cult_of_Skaro)
Comment: Probably the Cult of Skaro, but another possibility is Alpha, Beta and Omega the humanised Daleks in The Evil of the Daleks
Answer: There is an episode (somewhere during number 10 I believe), where four Daleks build a more durable (and slightly larger) Dalek. The first thing all five Daleks agree upon is that the new Dalek is superior and therefore must exterminate its four builders, which it does and they don't resist at all. They do this even though only the container, not the organism within, is different.
There was an asylum of the Daleks where all Daleks showing the slightest deviation are deported to, not to ever leave the planet. Deviation from "normal" is not acceptable. There is deportation instead of trying to migitate or even embrace the differences.
Difference will always result in classification superior/not-superior and lead to drastic actions, to uphold that "the Dalek" is the supreme being. They must believe their very existance is perfection and fight everything else.
Biological reproduction (even mythosis) does not guarantee exact clones, and therefore makes the entire process unfit for the Daleks. You don't want/need evolution once you are perfect. Having corresponding organs would be inefficient and leave room for improvement, which contradicts the assumption that a Dalek is perfect. From this we can conclude, that Daleks cannot be different from one another, not even in the slightest. There is no room for diversity, not even genders.
Once upon a time there may have been (probably were) Daleks with genders, but they would have eliminated this difference one way or the other way back in their history.
The original answer before the edit, which people seem to have problems understanding:
If there were discernable genders within the Dalek race they wouldn't be able to settle on "equal". One would always think its gender is superior or inferior to the other. For the nature of the Dalek, if there are alive Daleks they must be of the same gender.
Comment: Downvote for the huge unjustified assumption that gender dimorphism would always imply some sort of sexual power struggle.
Comment: @Chisti... not agreing with his answer, the validity in his reasoning is sound  for  most if not all animals with gender do have a domineering gender if they are not contantly feuding; even we as evolved and rational as we are still unable to find some form of genderequality. Bonobo's a puigmee chimp(younger species than us so technically more evolved) is the only species that has had success in uniting the genders without a superior and that is through the compulsive sexuality of the creatures in social situations
Comment: @Christi: They're Daleks, their very nature is to hate and believe they are superior. They were made that way. For anything that classifies species the Daleks _must_ believe they, their making, is superior. Of course that includes gender as well. That's the smallest and most justified assumption I'm making.
Comment: Daleks have power structures, chains of command, and specialized skill set Daleks (classic who, but seen in Asylum of the Daleks). Gender would not specifically be any more of an issue than that.
Comment: @cde: assumed roles in organisational structures and assigned specialised skill sets are very different from discernible physiology. Assuming the Daleks have an acceptable form of biological reproduction (without the flaw of mutation) i'd say it can only work if any Dalek can assume any gender at will, making them unisex and therefore of the same gender. They may fulfill different tasks, Daleks must not differ from one another or they will classify and identify one class as superior.

Do daleks have gender?


How expensive is it to migrate from AES-128 to AES-256

Question: How feasible would it be to migrate from AES-128 to AES-256?
Comment: On the other hand, if the users already hold 128-bit keys, the cost of moving to 256-bit keys is at least the cost of distribution of new keys to all users. In a business where millions users hold their keys on Smart Cards, that cost alone would be a show stopper.
Comment: [40% overhead of AES-256 over AES-128 with AES-NI](https://crypto.stackexchange.com/a/76746/18298), And the increased rounds 10 of AES-128 to 14 for AES-256 is verified. Is this what you wanted or deeper than this like the cost of generating double-sized keys and storing them, available hardware, password strength to derive keys, etc.
Comment: You may have the cost of updating the software as well. No good using 256 bit keys if your software doesn't know what to do with it
Answer: As you may have found out it depends on the specific system where this can be applied. If AES-256 is supported then the algorithmic overhead is usually limited; it would possibly only be a problem when it comes to embedded devices.
As also mentioned, key management is probably the biggest hurdle. Re-establishing keys can be really hard. It can also be very simple; e.g. you could simply reconfigure the cipher suites of TLS, and since the (ephemeral) symmetric session keys are established during the handshake, you would probably not even notice the change. However, if the keys have been pre-distributed then replacing the keys from a trusted source maybe costly, possibly prohibitively so.
For hardware: there are certainly embedded CPU's systems that only support AES-128 hardware acceleration. Due  to the puny CPU's it may not be feasible to run AES in software. In that case AES-256 is probably a no go. Most modern CPU's in PC's support AES acceleration for both key sizes on the other hand.
For protocols: AES-256 uses 32 byte keys. This can be an issue if a your key derivation mechanism only outputs smaller amounts of bytes (say PBKDF1 with SHA-1), or is inefficient (say PBKDF2 with SHA-1) if you retrieve too many bytes from it. On the other hand, the block size of AES-128 and AES-256 so if the block cipher is seen as a black box, then the input / output (plaintext / ciphertext) requirements won't change.
Similarly, if you have a large disk that is encrypted with AES-128 then re-encrypting it using AES-256 then you may have to wait a long time before the process is finished, not so much because of AES but because of the I/O.
So without further information: it depends, it can be a single configuration string or it may not even be possible and everything in between...
Comment: the main issue for embedded AES128 with limited memory would probably be a rolling key schedule, that does not store any subkeys except for the active one


Headphone Jack Detection

Question: Sometimes my headphone jack stops working and I need to restart my computer. I can also put the computer to sleep and it will wake in the proper mode (headphone vs. speakers). Is there a way to reset whatever is causing this problem without restarting?
Comment: Go in sys pref sound and cycle the output
Answer: Double check to make sure there is no dirt in the headphone port - there is at least one sensor there that might be dirty and making it hard for the system to tell what is or is not plugged into the port. Blow it out with compressed air and/or carefully remove whatever is in it with a toothpick.
http://www.instructables.com/id/How-To-Clean-A-HeadPhone-Jack/
In many Macs, the headphone jack also has optical audio output in the same port, so if some dirt is in there, the system might think an optical cable in plugged in, so the headphone circuit will be turned off. If the system preferences says "digital", than probably this is what has happened.

Headphone Jack Detection


Sigma algebra generated by random variables

Question: Im currently studying for an exam in probability theory and one example in the lecture notes stated the following: Let $X_1,X_2,...$ be i.i.d. random variables. Then $\sigma(\{X_i:i\leq n\}) = \sigma(\{S_i:i\leq n\})$, where $S_n:= \sum_{i=1}^{n} X_i$. I don't see why this statement is true, maybe its some measure theoretic standard argument, but I just don't see it. Any help is really appreciated, thank you in advance!
Answer: Write $S_i=f_i(X_1,\ldots,X_n)$ where $f_i:(x_1\ldots,x_n)\mapsto \sum_{k=1}^i x_k$ and note that $S_i^{-1}(A) = (X_1,\ldots,X_n)^{-1}(f_i^{-1}(A))$, so that $\sigma(\{S_i:i\leq n\}) \subset \sigma(\{X_i:i\leq n\})$.
For the other inclusion, note that $X_1=S_1$ and for $i\geq 2$, $X_i=g_i(S_1,\ldots,S_n)$ where $g_i:(s_1,\ldots,s_n)\mapsto s_i-s_{i-1}$.


How do I add a custom-built theme to Keynote for iCloud?

Question: I'm just after finishing the creation of a custom theme for my wife's new company. We created it with Keynote, and then backed up the .kth extension file and sent it from her computer to mine.
She's able to load it from her Keynote app on her OS X El Capitan. I was able to open it via email, and add it to "My Themes" onto my macOS Mojave, and later opened it on the iPhone and added it to "My Themes".
Then I decided to go and check out http://keynote.icloud.com .. And can only see Standard and Wide - but no My Themes.
So, how would I go about adding a custom-built theme so that it is available via Keynote for iCloud?
Is this even supported by the web-app Keynote for iCloud?
I tried dragging the .kth file into the Keynote for iCloud file browser, nothing happened. Then I tried clicking "Upload" and selecting the .kth file, which resulted in the following error:

Cannot upload this type of file to this App Library.
Only files that can be opened by keynote can be uploaded here.

Which is somewhat bemusing, since Keynote can open the file. Just not Keynote for iCloud.
Any ideas?
Answer: From research across many forums, I cannot find any indication that Keynote in iCloud, as of 2019-11-01, supports Keynote themes.
Hopefully, in the future, there will be a more positive answer to the question