Is C++ much better than other languages?

Question: I am learning C++. I learned basics concepts  and OOP. The main things peoples are working on are GUI and API development with the help of C++. My question is, as a C++ learner is it a must for me to learn these in C++, because there are other languages to learn and develop these concepts (GUI , APIs ...)?
Comment: What are your actual goals. Do you want to just become a developer or do you want a deep understanding of computing in all of its facets?  Is your goal graduate school and beyond or not?
Comment: @Buffy : yes I want deep understanding  of computing !!!
Comment: @Rusi sorry, I hope I didn't come across meanly, certainly nothing inappropriate! My own experience is that such discussions can confuse and disenchant beginners (regardless of their merit), but I don't have anything like the teaching experience you do.
Comment: If you look at Linux running... Lets see... from desktops to Android to most of the world's cloud servers to random devices IOTs modems... etc, Linus Torvalds is arguably the world's greatest programmer. And this is his view of C++ http://harmful.cat-v.org/software/c++/linus . Ten years on he seems to not have changed his mind https://medium.com/nerd-for-tech/linus-torvalds-c-is-really-a-terrible-language-2248b839bee3 .Do I believe Linus???  That's a non-trivial question and you will have to ask it with some care and research to get good answers.  If you dont your questionsstart getting closed
Comment: @Rusi : But in my case i prefer the languages  which is best in there fields/use . for example we use python for DS , ML etc.  And also use its framework for backend web development .On the other hand we use Java or Swift for app Development . and most of programmer who prefer me to learn C++ as a beginner and for DSA .
Comment: @Rusi What I've read of Linus' comments on C++ can be said of any high-level language/process/anything: it introduces useful features which everyone can understand, but which inevitably are not perfectly suited to every scenario to which they are applied, so there is always dissonance. The fact that everyone and his dog can use those features and that you don't have to re-implement them for each and every project is a massive practical benefit that he clearly values less than his performance considerations. Personally, I would encourage people to ignore such debates when learning.
Comment: You — we all — are free to choose our favorite desiderata (and bugbears) @VisualMelon. But you are misrepresenting Linus views as *performance considerations*, when he makes it clear that he dislikes C++ because «**C++ leads to really really bad design choices**».  I am not remotely in the same league as LT. And I am sure there are many great C++ programmers who would give strong arguments to him re C++. But I am teacher who's taught for decades. And I can vouch for the LT observation from the pedagogical side: **C++ early spoils kids**
Comment: @Rusi perhaps I am, for which I would apologise (to mention performance wasn't meant as a negative remark: it _is_ a real concern, but the point like any concern it is one among others, and without a serious project they cannot always be weighed); I must say I was unsure what your original comment is getting at, and personally I wouldn't point a newbie at that sort of thing (by LT or anyone else): I'd welcome some expanded discussion on the learning side of things in one of your full answers (reading back I'm not sure how much the OP knows already, and I was probably under-estimating it).
Comment: @VisualMelon Happy for a fuller discussion on some other q/as here! Regarding exchange with *this OP* see this recent comment thread https://cseducators.stackexchange.com/q/7252/8837. And if thereafter you feel something is still inappropriate/out-of-line I'd like to know!
Answer: There is nothing wrong with learning C++ as your first or main language. It's an extremely big and complicated language, but that's only if you want to learn everything about it. "Modern" C++, meaning C++11 or newer can actually be used as an elegant language to teach programming in. Try to find a book that teaches C++17: there is a lot in older C++ versions that has been improved and there are lots of tutorials out there that teach stuff you really should not use.
One of the main attractions of C++ is that you can write very high performance code in it. For example, C++ is really the language of choice for video games. But that's mostly for the deeper stuff, the actual video stuff. If you're interested in GUI applications you can use C++ but you don't have to. In your case I would let the choice of language be dictated by the platform you want to code for. If there is a de facto standard, use that.
Comment: The books by Stroustrup (the author of C++) are good, for instance "Programming, principles and practices using C++". However, they are expensive, so I hope your library has them. You can also check out my book: https://tinyurl.com/vle322course
Comment: yes you are right but which  resource is for learn new features of C++ ? there is site know as cpp reference but this one is not for me :( because i don't  understand  the concepts form documentation  . can you plz guide me !
Answer: I will try to answer this question from a Computer Science Educator point of view.
C++ is a tool
First and foremost, C++ is a tool. Like any other language, it's designed to make accomplishing certain types of tasks easier, but it always comes with a cost.
C++ tries to be usable almost everywhere with a great deal of flexibility. This inevitably comes with a cost of complexity. Some say it's the most complicated language out there (to know all the rules, not to accomplish certain tasks - this confusion leads to incorrect assertions that C and Assembly are more complex).
It can give you everything
Teaching C++ has its benefits. You can use one tool to teach pretty much everything there is - high level abstractions like generics, dependency injection with polymorphism, framework interactions, various package managing, resource acquisition and control, interactions with hardware in the lowest level.
It's convenient to be able to teach pretty much everything while using one tool. But it has its costs.
It is incredibly complex and makes some tasks disproportionately harder
Computer Science students have many reasons to learn a programming language. It is important to not only provide reliable information, but to also encourage them to explore the possibilities on their own. C++ makes it hard. Very hard.
Scott Meyers (a notable author from the C++ community) was once asked, what, in his opinion, is most lacking in C++. He said something among the lines of:

I am an author, so naturally I would want to know how is my book selling. I need to fetch those information from some online source, so in C++ I... yeah...
Okay, forget networking. I have the data and I want to display them in a nice chart, so in C++ I... yeah...

C++ does not have many of the common (some would even say fundamental) features that are expected to be bundled in the language. Most students will be way more amazed by easily making some simple GUI application than by creating a console game for the 5th time. There is still no networking or GUI application in standard C++, and C++20 is almost implemented by the Big Three compilers.
Not everything can be solved by a third party library
Some would argue that third-party libraries exist for a reason. What's the problem with introducing a simple dependency and using it? After all, every programmer should be aware of such possibility and get familiar with project dependencies.
Except for the fact that C++ makes it incredibly hard to bundle additional dependencies. It was designed before Internet-aware package managers were a thing. Some decisions have been made that made sense during that time. But new tools were being created and integration reached a new level. Multiple times I had to mentally sigh when I was asked by a student why it takes 4 hours of researching accompanied by trial and error to install OpenCV with CMake, while in Python it takes one pip command. The situation is bad and it's unlikely that it'll improve.
Every tool has its purpose
Every tool has its purpose and while C++ may as well be an academic language, I do not believe the pros outweight the cons in terms of learning programming. Make a distinction that is already omnipresent - don't use one tool to do everything, even though such a tool can be used with everything. Want to learn programming and get hooked? Chances are that Python, Kotlin, C# or TypeScript will be much more engaging and pleasurable experience. Want to start with or migrate to low-level language? Choose C or C++, but remember - nowadays C++ is not really used as a "just more powerful C". The "modern" part of it is more common and it's not really a tool used to primarily interact with hardware directly. Its aim is to provide a high level of abstraction with almost zero-cost overhead. This comes with complexity.
What to choose, then?
Ultimately, this is your question about your situation. You have learnt some basics of C++, good. It's not bad to make a transition to another language, nor is it bad to stay with C++. Ask yourself whether you're enjoying C++. If yes, try to delve deeper. If not, make a change. A programmer ough to know more than one tool, so learning more languages is inevitable.

A word of disclaimer - I have been programming in C++ for almost ten years. It is (and has always been) my primary language. I am engaged in both business solutions and education and, unfortunately, I more and more believe that my favorite tool (C++) is becoming more and more ill-suited for being an academic tool. Want to teach high-level? Use Kotlin, Python, TS, C# or Java (or other tools that make it easier by doing some work for you). Want to teach low-level? Use C.
Don't bother with the fact that C++ can do both of those things, unless you have a very good curriculum planned. "Can" doesn't mean "should".
Comment: "GUI application [versus] console game for the 5th time." There is more to life than graphics and games. I teach "scientific programming", and my students do stuff like infectuous disease propagation, delivery truck planning, climate change, et cetera. (At the end of their first semester.) All of those require substantial programming, and with no ancillary libraries. If they want to visualize something, they pipe their numbers into some simple graphing tool. I guess it depends on your audience. Just don't think that your audience is representative. Mine isn't either, but I don't generalize.
Comment: @Hamza C++ *can* be very close to the hardware. Python *is* very far from it - by design. C++ has *language features* that enable you to interact with hardware directly, but Python needs *library features* to do the same. What's more, those libraries that Python relies on are usually written in C or C++!
Comment: You say "but remember - nowadays C++ is not really used as a more powerful C." And I say, any time someone says "remember" they are about to say something completely unsubstantiated. Case in point: I write a lot of stuff that I could write in C, but C++ 1. has automatic memory management, so no leaks 2. parameter passing without having to count "**"s. Seriously, how do you teach students to write a routine that outputs a malloc'ed array in a parameter? 3. Arrays know how long they are through ".size()". 4. The copy constructor. In C you have to write your own copy routine. Horrors. Etc.
Comment: @VictorEijkhout there are no universal points that hold true for every single instance, although by "nowadays C++ is not really used as a more powerful C" I didn't mean that C++ cannot replace C in certain areas. It can, just as you explained. But many people tend to treat C++ as the same hell with `**`s and lack of memory safety, *but with classes and templates*. This is what I meant by "more powerful C". C++ is not C. It's not an add-on. It's a completely distinct language in which you need a different mindset to program compared to C. And I feel like you proved my point in your comments :)
Comment: Ok, if you're talking about "C with classes", yes, that is pretty much universally recognized as a bad idea. See Kate Gregory's "Stop Teaching C" talk. I see you've edited your answer to clarify, so I guess we agree. Except that I think C++ is great for getting close to the hardware, on anything but a Linus Torvalds level. I do my bandwidth/associativity/false sharing epxeriments all in C++. It's just easier to write for the reasons given. So I'm far less down on C++ than you are. But I'll grant you the network/graphics/package manager points. That's why I also speak python.
Comment: I've seen "Stop Teaching C" around 5 times. It's a great talk! I also agree that C++ is great for getting close to the hardware. I just don't think that if the goal is to teach hardware interaction, it is wise to choose C++ over C and bring the whole complexity package with it. My high-level language of choice is Kotlin. Have done some serious things in Python and dynamic typing seems to not really be my thing :)
Comment: @Fureeish : can you tell me how C++ is close with hardware  as compare to python ?
Comment: @VictorEijkhout "C with classes" is substantially better than "C without classes".
Answer: As a software developer, I used C++ on several projects.

First I learnt C.
Then on the first C++ project I learn encapsulation.
Then on the third C++ project I learn some more.
Then on the forth C++ project I learnt Eiffel. In Eiffel I learnt polymorphism, inheritance, generics (templates), return type covariance, etc. ...
I then learnt how to do these in C++.
Then realised that C++ is a bad idea: It has some improvements to C, but also a load of blot, that gets in the way.

I wish I had learn Eiffel first, it is a much quicker language to learn. It is quicker to learn Eiffel and then C++. Eiffel is also a much quicker language to program in. And compiles to programs of similar speed to C++: faster for big complex programs, slower for simple programs (but not much).
Conclusion:

Learn to program: Eiffel, Lisp.
Use a high level language for most jobs.
Use a hybrid of languages when you need to do low-level stuff.
Use golang, Eiffel, or if you must C, for speed. There may be others.
Comment: Eiffel... Yeah it's a good reminder.  70-80s Pascal was the de facto teaching language. 80s shifted to scheme.  Eiffel never became as big as these but it (was) still a good teaching language in the 90s.  Post 2000 everyone's jumped onto some industry omnibus such as Java, Python, C++. And this baby — to teach programming one needs a *teaching oriented* language — is forsaken and destitute
Comment: Eiffel  ? can you plz explain what is this ? btw I know the concepts of OOP but I don't know about modern C++ .
Comment: `Eiffel` is an OO language. When you have used it, you will realize that `java` is not real OO. (smalltalk is another interesting OO)  It compiles to `C`. It is fast. It is easy to learn. It is easy to use. It is powerful.
Comment: much batter then C++ . ?  : |


Cannot open /dev/rfcomm1 : Host is down

Question: I am working on raspberry PI and on Bluetooth. I am using old raspberry pi kernel as the new one has got some bugs that were not resolved with respect to the bluez daemon. At present my kernel version is 3.6.11.
I am using a USB bluetooth dongle and my sole purpose is to auto connect the bluetooth dongle when ever it is in range. For that i think i have to run a script in the backend on RPI that will keep on checking the existence of usb bluetooth dongle. I started from the very scratch. I installed bluez daemon using
apt-get install bluetooth bluez utils blueman

and then i used
hciconfig

which gives me that my bluetooth usb dongle is working fine. But when i did
hcitool scan

, it give me no device in range even though my Serial bluetooth Device was on. I wasn't able to find any device in vicinity. Also when i unplugged and plug the USB dongle again, i was able to scan the serial device , but when i repeat the process, i find the earlier condition of not finding any deice. I had find another useful link, but that need address of the bluetooth device that need to be connected. I want to automate this using hcitool scan, storing the output to the a file and then comparing it with already paired devices and their name. For that i need to figure out why hcitool scan is sometime working and sometime not. ?
Can some one help me in figuring out why this is happening. Is there any problem on
hardware side i.e Bluetooth dongle is buggy or i had some problem in bluez utils.
Edit 1: While as of now, hcitool scan is giving me my remote device address but still i am getting the same issue of HOUST IS DOWN, '/dev/rfcomm1'. I am really not getting any idea of what to be done.
Answer: I don't know what i did or what happened randomly, i am able to get the hcitool scan results after i used sudo apt-get install python-bluez. Also i find that hardware was a probable faulty thing i was having. When i switched the USB-BLuetooth dongle , things work fine.

Cannot open /dev/rfcomm1 : Host is down


How to fill in a UK visa application form if you have no surname on your passport?

Question: I do not have a surname in my passport.
How do I enter 'Given Name' and 'Family Name' in my UK visa application form?
Comment: @TheLuckless RE: "'universal name format' that reliably covers all the options", see this classic article: https://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
Comment: Adding what culture your full name style comes from may be helpful in providing a useful answer. [Sadly it has been a slow process to shift world wide bureaucracies over to some kind of 'universal name format' that reliably covers all the options.]
Comment: In my passport there is no surname only given name but i cannot leave surname blank in visa application what to write there?
Answer: There is an answer here http://www.immigrationboards.com/uk-tier-1-post-study-work-visas/no-surname-to-enter-online-dependent-visa-application-t122774.html from 2013 that indicates entering '-' is acceptable.

I had a similar issue with my wife's passport. I had put '-' in the surname field.
Visa was granted by the high commission in Chennai. In the receipt her name was 'firstname' 'firstname'.  However on the visa her name was only 'firstname'
She recently came to the UK, and there were no issues in immigration etc, except that the Indian immigration authority suggested that I include my name in my wife's passport.


Textbox with calaneder extender looses its value

Question: my textbox which has a calendarextender attached to it behaves inconsistently. Most of the time, after selecting a date and submitting the form, the textbox does not have a Text value (i checked using quick watch). After rebuilding (without touching anything) it works as it is supposed to be. but after navigating through the site and and returning to the page, sometimes it works, sometimes it does not.
Answer: You need to set the CalendarExtender's selection on your last chance in the page cycle:

    void Page_PreRender(Object sender, EventArgs e)
    {
        if (dateFromAnotherPage != null)
        {
            CalendarExtender1.SelectedDate = DateTime.Parse(dateFromAnotherPage);
        }
    }


Asp.Net web app read query performance

Question: using EntityFramework 5 (POCO),  SQL2012, ASP.NET-MVC4.
My problem is that, my app runs slow, the reason is that the technology stack I mentioned above uses the same connection for different queries running on the same server.
Lets say we have two different queries, one runs slow (up to a minute), another one quite fast 1,2 secs. Even on the test server when there is only one user and that is me, if I open two different browser windows(sharing same session),and execute the long query first and then the quick query next at the same time, and when I query the running sessions on the sql server for the active ones I only see one session, and as a result, the quick query also gets stuck waiting on the slow query.
I tried couple of things and got random results:
I disabled pooling on the connections string;
<code>Pooling=False;
</code>
Sometimes it ran those queries in two different sessions, sometimes in one. I set the min pool size to 10, I think until hitting the min pool size, it was okay, then it started using the same db session.
Another thing is that MARS was enabled by default;
And I tried removing that, (I do not know the full impact of this atm, I have not tested everything, so actually I intend to leave this enabled.) and I again got random results.
I used two different browsers, so 2 different IIS Sessions, and got better results. It opened up two db sessions for each query.
We use MSDTC so all the transactions run in a transaction context and this leaves all open connections in Serializable setting, as a result we had to run read queryies also in Transaction Scopes and opted for Read Uncommitted isolation level in that one.
So having quite a capable SQL Server, how can I prevent ASP.Net/ADO.Net/EF5 from using a connection that still has a query running on the server.
PS: I instantiate DbContext by passing in a connection string to the DbContexts's constructor.
The queries running above are on two different contexts.
Answer: this seems to fix the problem.
<code>[SessionState(System.Web.SessionState.SessionStateBehavior.ReadOnly)]
public class SomeController: Controller
</code>
If you set the session state to readonly, Asp.Net MVC lets you have multiple queries running at the same time.

Asp.Net web app read query performance


Is editing geometric network in versioned geodatabase any different from when such data is stored elsewhere?

Question: I need to work on "Checked Out" version of a geodatabase, editing geometric networks. What will be the difference in terms of the working process of the editor ?-do i need to use some special toolbars ? is it possible to work on versioned GDB with ArcEditor 10.1 ?
Comment: What "difference" are you referring to? Can you provide a more complete description of the editing workflow you are currently following and *specifically* what you are proposing to change? Do not assume we know your data or your processes. Also, try to narrow down the topic to something answerable with a few paragraphs, and demonstrate that you have reasonably researched your question. An exposition on versioned editing is too large a topic for this site, although you might get close with an answer like [this](http://gis.stackexchange.com/a/15344/753).
Comment: A couple points of clarification: 1) the term "ArcEditor" refers to a license level. At 10.1 they changed the names of the different license levels from ArcView, ArcEditor and ArcInfo, to Basic, Standard and Advanced, respectively: http://support.esri.com/cn/knowledgebase/techarticles/detail/17134 2) You are able to perform versioned editing at Standard (ArcEditor) levels and up, but not at the Basic (ArcView) level: http://www.esri.com/software/arcgis/about/gis-for-me
Answer: I don't understand exactly what you're asking.
Read this to learn about the different replication types:
http://resources.arcgis.com/en/help/main/10.1/index.html#/Replication_types/003n000000t6000000/
A checkout will either be a personal or file geodatabase. It should look and feel the same as editing from an SDE database. It's just a copy of the SDE data that can be worked on in a disconnected environment and then is checked back into the SDE database when you're finished editing. Any edits you make will be applied to the server once your data is checked in.
And, yes, it is possible to work on a versioned geodatabase with 10.1.
Answer: You don't need to worry about this. Working with the checked out geodatabase is not different than working with a non versionned data: all the work is on the side of the default version.
What you need to care about is to make sure that you don't have a conflict between your ArcGIS release and the one where the data comes from (see here). If you version is higher, do not upgrade the gdb!


Determine whether a file has no EOL at the end from the command line

Question: If you open a file in vim and that file has no EOL at the end of its last line, then the editor will report it as [noeol]. How can I determine this before opening it in vim? (Is there a command I can issue to determine this?)
Comment: Thanks for asking for clarification. The issue is that I want to identify whether a file has no EOL at its end from the command line, plain and simple. I do *not* have any additional requirements such as identifying this only for files that are about to be edited.
Comment: I'm curious to understand what you would want to do about it if you could determine whether or not the last line is ended with a newline character. Thanks.
Comment: I would then issue `echo >> file`. I am dealing with many files, some of which have this condition, and I would prefer to determine this without having to open `vim`.
Comment: Would it be correct to say that the issue you want to identify (and fix) files that have no final newline? Or is there a definite restriction that you want this identification to occur only for files that are about to be edited?
Comment: Related https://unix.stackexchange.com/q/31947/100397
Answer: tail -c 1 outputs the last character (more precisely, the last byte) of its input.
Command substitution strips off a trailing newline, so $(tail -c 1 <…) is empty if the last character of the file is a newline. It's also empty if the last character is a null byte (in most shells), but text files don't have null bytes.
Keep in mind that an empty file doesn't need an extra newline.
if [ ! -s "$filename" ]; then
  echo "$filename is empty"
elif [ -z "$(tail -c 1 <"$filename")" ]; then
  echo "$filename ends with a newline or with a null byte"
else
  echo "$filename does not end with a newline nor with a null byte"
fi

Comment: Ah, that's a much better answer than mine. I was wondering why `if [ $"\n" == "$(cat test | tail -c 1)" ]; then echo "yes"; fi` wasn't working
Comment: @DJMcMayhem: in addition to the trimming issue, `$'..'` (singlequotes) is for interpreting escapes like `\n` but `$".."` (doublequotes) is for translating to other languages (more exactly, locales).
Answer: Create a file with only a newline character in it, then compare it to the last byte of your file:
printf '\n' > newline_only
tail -c 1 your_file | cmp -s newline_only -

I used cmp -s to make cmp basically silent. The exit status 0 indicates there is a newline character at the very end of your_file.
If your_file is empty, the exit status will be 1. You may want to make an exception and get 0 in this case. If so, prepend a newline to what cmp gets via its stdin:
( printf '\n'; tail -c 1 your_file ) | cmp -s newline_only -
# or
cat newline_only your_file | tail -c 1 | cmp -s newline_only -
# or better
<your_file cat newline_only - | tail -c 1 | cmp -s newline_only -

The last one is somewhat better because it will return non-zero exit status if your_file doesn't exist, cannot be read etc. If I were you I would want this. Although if your_file is in fact a directory then cat, tail and cmp will run and you may get 0 and a complaint from cat; or may not, see this: When did directories stop being readable as files?). Therefore you may want some additional logic or option (e.g. set -o pipefail in Bash).
Notes:

In some shells you can use process substitution to avoid creating the newline_only file. It will be like:
# e.g. in Bash
< your_file cat <(printf '\n') - | tail -c 1 | cmp -s <(printf '\n') -

tail reading from a pipe cannot seek. cat needs to read the entire your_file, only then tail can do its job. tail -c 1 your_file or <your_file tail -c 1 may be smart enough to seek within your_file. This should be negligible if you test one or few small files though.
This other solution will probably perform better: it doesn't create files; it doesn't pipe into tail; it doesn't spawn cmp; it uses [ which is a builtin in many shells.
Answer: This doesn't really have anything to do with vim. Pretty much you want
tail -c 1 file

to get the last character of the file.
Comment: If the last character is a space, or a tab (which displays as one or several spaces), then no character 'appears' (is visible to a human), but the file does have an unterminated last line.
Comment: I think you can improve that: `noeol(){ test "$(tail -c1 "$1"; echo x)" != $'\nx'; }` (you can simply use `'x'` instead of the non-standard `$'...'` syntax -- that's impossible to enter in a comment). Unlike @gilles' answer, this does not need special casing for empty, zero bytes, etc (`bash` will always warn in the latter case, though)


Photons at the big bang

Question: Did photons exist at the singularity of the Big Bang? If they did not, then does that mean that it is impossible to see what happened at the big bang?
Comment: As far as I know, it would be not correct to call the Big Bang a singularity, as we don't know for sure how closely it resembled anything we presently categorize as a singularity related event. In other words we just don't know **what** the Big Bang was, or how it "appeared", we can only say what occurred after the Big Bang. The link in Heather's answer is well worth reading, but I think it carefully avoids attributing a definite cause to the Big Bang.
Answer:
Did photons exist at the singularity of the Big Bang?

You are discussing a cosmological model with a singularity, which is not considered a good model, since when singularities appear in classical physics, and General Relativity is a part of classical physics,  quantum effects take over and modify the results. Example the hydrogen atom. Classically an electron and a proton are modeled with a singularity of the potential, 1/r , and classically there could be no hydrogen atom as the electron would finally fall on the proton and disappear. Quantum mechanics solved this by the fixed energy ground level of the Hydrogen atom solution of the Schrodinger equation.
The standard cosmological model still called Big Bang has no postulated singularity at the beginning any longer, an effective quantization of gravity model is used and the quantum mechanical "particles" present in the postulated beginning of the universe are the inflatons.

Timeline of the metric expansion of space, where space (including hypothetical non-observable portions of the universe) is represented at each time by the circular sections. On the left the dramatic expansion occurs in the inflationary epoch, and at the center the expansion accelerates (artist's concept; not to scale).

The inflation period postulated instead of the singularity with quantum mechanical arguments has no photons.
As the universe cools quarks gluons electrons etc appear in a plasma soup , and before symmetry breaking all particles have zero mass, i.e. are photon like. What will develop into photons are the four gauge bosons which are all photon like because their mass is zero.

Inflation ended when the inflaton field decayed into ordinary particles in a process called "reheating", at which point ordinary Big Bang expansion began. The time of reheating is usually quoted as a time "after the Big Bang". This refers to the time that would have passed in traditional (non-inflationary) cosmology between the Big Bang singularity and the universe dropping to the same temperature that was produced by reheating, even though, in inflationary cosmology, the traditional Big Bang did not occur.

At symmetry breaking , when the universe has cooled enough, the gauge zero mass particles become the Z W+/- and the photon, so that is the first appearance of the photon as we know it, at 10^-36 to 10^-32 seconds after the beginning of the universe.

If they did not, then does that mean that it is impossible to see what happened at the big bang?

We can only model what happened at the fuzzy beginning of the Big bang with the data we can gather. The Ligo data show that we can measure gravitational waves, so that would give us a handle for measurements on the inflationary period, before the electroweak period, if smart enough exeriments can be proposed and devised. At the moment it is with photons that we have a picture of the early universe, and their measurement gave the data that required to model the beginning of the "bang"  as an inflationary quantum mechanical period.
Answer: Well, photons were at the Big Bang, but it wasn't light that we can now observe until the era known as recombination, about 378,000 years after the Big Bang, that photons had a practically infinite mean free path due to the majority of protons in the universe being bound up in neutral atoms, and the universe became transparent.
Before then, the universe did have photons, but you can think of it as the mean free path for the photons not being long enough for there to be any light. The universe was kind of "foggy".
Hope this helps! I'd suggest reading a bit about the different eras surrounding the birth of our universe; the wikipedia page is pretty good.

Photons at the big bang


Biochemistry/Computer Science BS applying for top 10 Computer Science PhD

Question: I am currently an undergraduate student at a large state university.
I have good grades (>3.90 GPA) in Biochemistry and I am now adding computer science courses. I am doing equally well in those (>3.80 GPA). But the majority of my research is in biochemistry. I did my honors thesis, worked in a wet lab for two years, and have two research publications. But these all have nothing to do with computer science.
I am really happy with the people in biochemistry and molecular biology, but not with the field itself. My biology advisors tell me I can probably do very well for myself in biochemistry. But I want to do computer science, since that is where my interests really lie. I like making algorithms out of strange algebras that don't exist and really fancy statistics that pretend they can think, and that is almost non-existent in my field of molecular genetics. I am not a fan of bioinformatics.
I already have research experience. But it might not be the right type of research experience. Nor do I have CS internships. Just lots of biology. Should I apply for those phd programs now, or should I wait until I have more research in computer science before I apply for Ph.D. programs?
Now suppose I apply for these top ten Ph.D. programs and I am rejected. How are reapplicants viewed within the academic cs community? Can I try again after a stint in your average brand-name company?
Comment: Why not just apply to a mix of top and middle ranked PhD programs as well as a few MS programs?
Comment: That's a really good point. But I also want to know about the higher phd places
Answer: In navigating my own applications over the years, I'm led to believe that the most important thing they want to know about you is are you going to be a good researcher. That you have publications in a technical field helps you a lot, it demonstrates you know the process one must go through in pursuing original work.
I will say that going straight to a PhD at a top 10 university in the field is somewhat of a leap without having much CS background, they won't have much evidence that your research interests are well-developed and that you are really serious about sticking with studying computer science at that level for 5+ years. But if they like what they see from your research and undergraduate coursework and recommendation letters (VERY IMPORTANT), then they will often just have you take a handful of pre-requisite courses at the beginning to get you caught up to where they think a beginning PhD student should be, e.g. taking some upper-level undergraduate classes that give you a good breadth of CS knowledge.
You would have a much better shot at getting into a Masters program in CS coming from your position, if you are willing to fund it yourself or take out loans. Oftentimes your PhD funding comes from a member of the faculty and so they need adequate convincing that you're worth the money.
My advice would be: apply to a few top 10 PhD programs you think you'd be a good fit for, apply to a few middle-tier PhD programs to give you some options, and then apply to a few MS programs if you think you'd be willing to go that route. You'll probably get an MS acceptance somewhere, you have a good shot at getting into a middle tier school, and you never know! They may just really like your application bundle and you might land a golden seat at a top 10.
And if you don't like the results, spend a year or two doing things to improve your application (CS research, online classes, work through problems in well-known textbooks, get a MS degree, read A LOT of papers and develop very specific research interests, etc.)
Answer: I actually see that you need to revaluate your Priorities about the so called Top 10 Universities.
I now see that the so called Top Schools are just Ranking Junkies.
Apply to lesser Known Schools in the USA Canada or Europe because the Top Schools attract too many Applicants for just 1000 Spots.
In 2002 Harvard Attracted 22.000 Applicants and now in 2020 it attracts 39.000 Applicants just for BA Degree Levels.
Top Colleges are now behaving like Corporations making money or mining their Students instead of Giving formal Education to their Patrons.
Hence Lies the Tragedy of College and University Education in the Western World.
So many students graduate with huge Student Loans worth averagely 45.000 US Dollars in the Grand Scheme of affairs.
College more important especially when it comes to Medecine Engineering and the Law.
Other subjects are just taking up land and Campus Space.
Besides one can also learn in the library and do Online Courses to add to the University Diploma Gained.
Less Known Colleges and Varsities have time for you and will enable you to become Outstanding at your Pace.
You see College must go at the Pace of your Intellectual Ability
Loren Pope said there is life beyond the Ivy League so do not at all disregard the State Schools and Universities in the USA Canada and Europe.
Be humble and get into a lesser Known to avoid Wasting Dollars and Precious Time in So Called Elite Schools.
Think about it we are the all the same humans no matter the School we attend for a Diploma or a Certificate.
The Editors who create Rankings assume that creating a Social Class will get People a sense of Ego Snobbery and Nepotism.
If one can write and understand Good English then one has a leg up un the World of Academia and Graduate Schools.
Comment: Why not stay in Biochemistry than Join the Queue for Computing.
Comment: In Africa we suffer from Power Cuts on a regular Basis and  Getting a PhD in Computing will not really help us a lot.
Comment: African Universitis  are granting Masters and PhD under Conditions that most Wwestrn Students cannot imagine as some Schools do not even have enough Libraries and Computer Centres for EditING and  Thesis and Dissertation  Submission in the year 2020.


If you accumulate 100 identical spheres into a sphere shape, how many will be on the surface or touching a sphere on the surface?

Question: I have asked this question in physics, math and chemistry (see my other sites). I have gotten some good advice but no definitive way to determine this. I am surprised there's not already a program to determine questions like this. I thought I would reach out to you guys and see what you thought. Anyway if I knew anything about programming or the capabilities of engines like Blender I would imagine Each sphere having a repulsion to each other at close range but overall a strong attraction to each other so that overall an accumulated symmetrical and spherical shape forms. Then once the accumulation forms could there be a way to count the surface spheres and the interior spheres?
Comment: related https://www.youtube.com/watch?v=cmdOmOCfo90
Comment: I thought blender was capable of creating 3-D animation?. Could you at least advise another program where I could ask this question?
Comment: Probably if you can attach some reference image to illustarte that. If you are looking for automatic way you would have to ask for some script.
Comment: Interesting Question. Can you elaborate how percise or scientific your interest is?
Comment: I had some interesting results with rigidbodys and force fields but came to a point were i had doubts if the behavior is part of the phenomenon or lays in some specifics of how forcefields work in blender internaly. You should experiment with one strong negative forcefield and and weak forcefields with small max Distance parented to your rigidbody objekts. Instanciate those via Particle System as suggested and play with the forces. Those could be controlled via drivers or Animation Nodes. The phenomenon in my setup was a strong momentum that formed a kind of radial galaxy motion.
Comment: @AM Thanks for taking interest. Your comment about radio galaxy is interesting. As far as my scientific interest goes, I would say it is physics. I asked this question in physics and math sections but got no answers. I thought I would reach out to you guys but I should be clear I know absolutely nothing about programming. I only heard about blender through my son. There are reasons I am interested in the subject and I have not elaborated on that yet because I need to know the answers to the questions I've been asking just to confirm some things. Again thank you very much for your interest
Answer: Rigid Body
According to your image you can use Rigid Body physics.

Add sphere as Particle in Physics properties add Rigid Body > type Active > Collision Shape Sphere
Add sphere as Emitter, enable Particles System > source Volume > Render as Object
Go to modifier properties and press Convert
Add sphere as Collider object, go to physics properties and enable Rigid Body > Passive > shape Mesh

When you finish with a spheres shaped into a ball (state in blend file) you can select spheres on a surface with Dynamic Paint.
In general - go to last frame of animation. Select all "particle" spheres and Join ⎈ Ctrl+J them into a single object. Disable Rigid Body and enable Dynamic Paint > Canvas > from Paint to aWeight. At the bottom you can see a red field of vertex group, click plus icon so group is created. Go to Data properties and unsure this data block is unique for this object and is not used for other object. If next the data name is some number (like 2 or higher) click on that. Then select "collider" sphere, scale it down so half of particle spheres on surface is out of collider sphere. Again disable Rigid Body and enable Dynamic Paint but now as a Brush type. Play once animation. Like that collider "paints" on all vertecies of particles inside collider. Now with particle object selected go to modifiers and Apply Dynamic Paint here. Now when you switch to edit mode and from data properties click on Select under Vertex Group all vertices inside a collider sphere are selected now. Invert selection Crtl+I and select Linked cmd+L. Now all vertices of spheres on surface are selected. Separate by Selection P. Now you have spheres on surface as separate object. To count them, simply Separate by Loose Parts P. Now you can see (in 2.91 text next to Tool shelf, left top corner of 3D view editor) how many spheres takes to cover surface.

For 180 spheres - 121 out / 59 in
For 100 spheres - 74 out / 26 in

Icosphere
Since any work with forces is a bit random (also thanks to more ways how to store spheres in the same shape as seen in lemon's link) you can try to use Icosphere as a base mesh for quite even distribution of vertices on a surface.

Spheres are distributed via Instancing - parent small Sphere to Icosphere ⎇ Alt+P and enable in Properties Editor > Object > Instancing > Verts
Comment: OK this is great. I've got it working now. Thanks again for your help.
Comment: Thanks for your input. Overall it's important that the programming have the two competing forces. (1) Each individual sphere is repulsing against other spheres the closer they get to each other. (2) all the spheres are strongly attracted to each other, and accumulate as close to spherical shape as they can. The two forces working together will smooth out the symmetric shape of the accumulated spheres. If you experiment with an actual handful of small spheres you will see that the packing goes from tight to lose and back to tight again as you add one sphere at a time.
Comment: Is there a way to make each sphere have a repulsion based on an inverse square?
Answer: Your question is quite interesting. As while messing with it, i found a way to remove particle collision, so first of all thnx.

coming to your question, your self proposed answer should work by using an emmiter particle system and 2 cahrge force fields + a drag force field:

But judging from your quistion you just want a sphere filled with spheres and seperate the outer layer?:
anyway here is both:

https://pasteall.org/blend/420d88beef3845e4994867956dbabfe6
Comment: Thanks for looking at this. Yes I am looking for a program or formula that will tell me the number of surface spheres no matter what the total number N is. I'm by surface spheres I mean any spear on the surface or a sphere touching a sphere on the surface. With 100 total steers that's not gonna leave very many on the interior. If you have a total of 200 spheres the interior will grow. As all the spheres accumulate the individual repulsion helps smooth out the overall symmetry of the accumulated sphere shape. Thanks
Comment: in your second image (The animation) did you use the two forces I suggested? (1) Each sphere repulsing against all the others the closer they get. (2) All the spheres strongly attracted to each other, causing them to accumulate into a basic spherical shape.
Comment: (1) each particle sphere has strong negative charge equal to its radius. and a small negative charge on a large distance.
(2) in the middle there is a seperate sphere that has a positive charge. If you simpely want to know how many spheres are on the outside you can just use particle systm that emits from the volume with a hexagonal grid distribution
Comment: He, i just searched for it, and apperently you can only fit up to 12 spheres within another sphere where there is an optimal solution known. https://en.wikipedia.org/wiki/Sphere_packing_in_a_sphere, so your question might be harder than it seems
Comment: No I am not trying to pack spheres into another sphere. Just take any number of equally sized spheres and accumulate them into a reasonably sphere shape.


How to merge many individual KML layers into one?

Question: I'd like to open a USGS KML file of bedrock geology for an entire county, but there are over 2,000 individual polygon layers.  Does anyone know if there is a way to merge all of these layers together into one file before opening in QGIS?
Comment: Your initial statement is a bit confusing.  Do you have one kml file with multiple polygons in it, or do you have 2000 individual kml files representing the bedrock geology types?
Comment: One thing you might do is use python and the QGIS API to do it.  This question and answer provides a means to get started:  [How to write standalone Python scripts using QGIS](http://gis.stackexchange.com/questions/30063/how-to-write-standalone-python-scripts-using-qgis)
Comment: I am not sure I understand, if I have a kml file with multiple lines, that would just open as one layer with multiple lines in QGIS. If on the other hand you have multiple kml files, you can open them all in Google earth, put them in one folder and export the folder as a new kml.
Comment: Yes it is one kml file with multiple polygon files. I was hoping for a plugin, because I know nothing about programming with python, but maybe now is a good time to start learning!  Thanks.
Comment: It seems foolish/dangerous to try to include all the files in one uber-file. A pain to process, and likely to cause crashing.
Answer: Here a simple shell script ("ogr_kml_merge.sh") which uses ogr2ogr:
#!/bin/sh

# Markus Neteler, 2008
# merge KML files

PROG=`basename $0`

if [ $# -lt 1 ] ; then
 echo "Merges KML files together (mosaik)"
 echo "Usage:"
 echo "  $PROG *.kml"
 echo "  $PROG a.kml b.kml c.kml"
 echo "At then end of the merge you can select a new name"
 exit 1
fi

LIST="$@"
OUT=file_merged

rm -f $OUT.kml

ogr2ogr -f KML $OUT.kml $1
shift

for i in `seq 1 $#` ; do
  echo "Appending #$i: $1"
  ogr2ogr -f KML -update -append $OUT.kml $1 -nln $OUT `basename $1 .kml`
  shift
done

echo "Written: $OUT.kml"

echo -n "Enter file name for new KML (or CTRL-C): "
read NEW
NEW=`basename $NEW .kml`
mv $OUT.kml $NEW.kml

echo "Written as: $NEW.kml"

Hope this gives the idea.
Comment: Tried it, but I get: `ERROR 1: Unable to open existing output datasource file_merged.kml`
Answer: One option would be to write a "wrapper" KML file and include links to each file in the wrapper, using the KML NetworkLink. Although it says "network", the Link element can contain a local file path instead. You can also use this in a KMZ structure
Comment: @ BradHards your link "KMZ structure" is not working any more.
Comment: @SIslam: the link has been updated.
Answer: Create a folder in which you'll then add the individual kml/kmz files. Go to Save as and in your destination, save this folder as a kml.Your result will be a single kml file. Hope this helps
Answer: With the plug in MMQGIS is possible to merge to many .kml files into one only shape file once you have uploaded all of you .kml files in Q-GIS.
To install the MMQGIS, simply you have to go to the plugin bottom, and select in manage sources and plugin.
Once the plugin is installed, go to combine, and after merge layers. Done!
Answer: I assume that the issue is not that there are multiple files, but there is a single KML/KMZ with lots of folders that is loading as individual layers, which is generally unsuitable for manipulation and performance.  You can see why this would be a problem:

Given that you asked how to merge all these layers together before opening in QGIS, there are two approaches:
Quick solution: Use KML Merger, an online tool located at https://kmlmerger.com/.  Do note that you'll have to feed it two KML files, so you might need to create a KML with no data present, or create a dummy KML with one element of your original data set, then delete that element in the exported file. This can easily be done with a text editor.
Automated solution: Try this Python script to flatten XML files.  It does read the KML line by line as if it were text, so it may not work on some valid KML files.

"""kmlflatten.py: reads a KML file as text, and strips out all Folder tags except the first and last.  usage: python kmlflatten.py IN [OUT]"""

import os
import sys

if len(sys.argv) >= 2:
    kmlfilein = sys.argv[1]
    if len(sys.argv) >= 3:
        kmlfileout = sys.argv[2]
    else:
        dotext = kmlfilein[kmlfilein.rfind(os.extsep):]
        fname, ext = os.splitext(kmlfilein)
        kmlfileout = fname + '_flattened' + ext
else:
    kmlfilein = 'doc.kml'
    kmlfileout = 'doc_flattened.kml'

with open(kmlfilein, 'r') as fi:
    with open(kmlfileout, 'w') as fo:
        folder, skip = False, False
        for line in fi.readlines():
            stline = line.strip() #remove indents, but hang onto original line.
            if not folder: #copy up to first <Folder> tag
                if stline == '<Folder>':
                    folder, skip = True, True
                    fo.write(line) # write the first folder!
                else:
                    fo.write(line)
            if folder: #copy lines except for the <Folder> tags and the <name> tag immediately proceeding
                if skip:
                    skip = False
                elif stline == '</Document>':
                    fo.write('\t</Folder>\n</Document>\n') # make sure to write the last </Folder> before done
                elif stline == '<Folder>':
                    skip = True
                elif stline == '</Folder>':
                    pass
                else:
                    fo.write(line)

A more suitable solution would be to use an XML parsing library to move all Placemark nodes into the first Folder, and perhaps first save any data about the Folder (like order or name) into the Placemark feature itself before it's destroyed.


Is there a cryptographic algorithm which is immune to side channel attacks?

Question: Is there any cryptographic algorithm immune to side channel attacks based on scan chain? In VLSI point of view.
Answer: A cryptographical algorithm can't be immune or not immune to side channel attacks; this is because a side channel attack attacks the implementation and not the actual algorithm.  Any algorithm that uses secret data can be implemented in a way that has side channel attacks, and any algorithm can be implemented in a way that may be resistant (the hard-core side channel attack guys will say that no implementation is totally immune) to side channel attacks.
That said, there are certainly algorithms that are easier to implement in a way that resists side channel attacks.
Comment: Some examples for the OP maybe?
Comment: Look at curve25519, it was thought in a way that counters side-channel attack by design. So that implementers can't hang themselves too much.
Comment: @David天宇Wong: can you point out what is in the design of curve25519 that counters scan chain based side channel attacks?  Or, for that matter, DPA or EMF side channel attacks?
Comment: _some_ side-channel attack! Sorry :) I know that the way it does point addition and doubling use the same amount of operations, and thus counters at least timing-attacks. Haven't read further
Answer: Often people build hardware that contains cryptographic algorithms, and they are worried about what happens if that hardware falls into the hands of an attacker.
Historically, there have been several approaches to making it harder for the attacker, often used in some combination:

Hardware and cryptographic algorithms specifically chosen or designed to comply with Kerckhoffs's principle: "A cryptosystem should be secure even if everything about the system, except the key, is public knowledge."
Then switch to a new, fresh key whenever an old key may have fallen into the hands of an attacker. (Perhaps also use zeroisation to make it less likely that an old key will fall into the hands of an attacker).
cryptographic algorithms specifically chosen or designed or re-implemented to be isochronous -- i.e., with data-independent runtime -- making them completely immune to timing attacks. (A good assembly-language programmer writing for a typical smartcard, which has no cache, can do this fairly easily. A FPGA designer can do this fairly easily. People writing code for processors that have a cache find that writing isochronous code is much more difficult, but often possible). (Unfortunately, this often makes such hardware slightly easier to attack with a differential power analysis side-channel attack).
*
Braun, Jana, Boneh.
Robust and Efficient Elimination of Cache and Timing Side Channels".
arXiv:1506.00189
discussion: https://news.ycombinator.com/item?id=9679762
*
Torbjorn Granlund.
"Defeating modexp side-channel attacks with data-independent execution traces".
https://gmplib.org/~tege/modexp-silent.pdf
A white-box algorithm is completely immune to side-channel attacks. white-box cryptography
white-box
http://www.whiteboxcrypto.com/ . White-box cryptographic algorithms are designed such that, even if the attacker knows everything about the system, including the keys for the hardware he has in his hand, he still cannot break the rest of the system.
This was widely believed to be impossible,
until ephemeral encryption keys, public key encryption, and public key signature authentication was developed.
There have been some promising breakthroughs in homomorphic-encryption and host-proof algorithms that seem to show that algorithms with useful white-box cryptographic properties are possible,
and a few have already been useful in practice:
(Public-key authentication using some certificate authority's public key happens every time a web browser accesses a "https://" website).
(Ephemeral encryption happens every time a laptop or smartphone communicates with a recent WiFi access point).
Unfortunately, we do not yet have a practical white-box algorithm for lots of other things we would like to do.
various techniques such as shuffling, dummy operations, etc. to make timing and power side-channel attacks more expensive and less likely to succeed
*
Stottinger, Malipatlolla, Tian.
"Survey of Methods to Improve Side-Channel Resistance on Partial Reconfigurable Platforms."
doi: 10.1007/978-3-642-16767-6_4
tamper resistance to make probing attacks more expensive and less likely to succeed.
Comment: When you say "isochronous -- i.e., with data-independent runtime", do you mean variable/random time but not based on secret data, or do you mean constant time (i.e. exactly the same number of time units)?
Comment: @Joost: I was thinking about the many systems that, every time some sensitive inner cryptographic function is used, that function always runs for exactly the same number of clock cycles. I thought the link in this answer would make it clear that such isochronous functions completely defeat timing attacks, in a ways that "add some random delay" is still vulnerable.
Comment: Right. There's another class of functions, though; those that are not vulnerable to timing attacks, but still take a varying amount of time (e.g. due to some rejection sampling from a PRG). My comment stems from the fact that there does not seem to be a clear word to describe such functions.
Answer: As others mentioned side-channel attacks are an issue of algorithm implementation.
djb implemented a full suit of cryptographic primitives specifically with side-channel resistance in mind.
The idea is to prevent infromation flow from your secrets (private keys, messages, etc.) to those pieces of hardware which can be easily attacked, like CPU branch predictors, caches, TLBs, etc. You can read in detail here.
Comment: The question specifically asked about scan-chain based side channel attacks; are you saying that djb's implementation protects against those attacks?
Comment: While it is an implementation issue at heart, it is true that an algorithm can be designed such that implementations free of side-channel attacks are more practical and performant.


Accidently gave essay notes to a classmate

Question: So at the last day of class a classmate asked if they could borrow some of my lecture notes for studying for the final (this was a history class). I said sure and sent them to their usb. Since it was near the end of class I was rushing to copy and paste my files and in that I think I also sent them my essay notes by mistake. I do not know their name and I have contacted the department head and my professor about the issue letting them know as I am worried they could use these notes in their paper. The notes are not my draft or final copy, they just summarise each article the professor gave for the essay, and the paper itself was well overdue at this point. The office told me I would not likely get in trouble but I still have worries as marking is ongoing. Have I done the right thing so far? Is there anything else I should do?
Answer: You have taken appropriate action already. If you meet up with the person warn them against using the notes. But, if you want some additional security, print out your notes and get someone you trust to sign and date them. Now you have a clear marker. I doubt that this is necessary, but if you are paranoid,...
But any infraction of rules would be by the other student, not yourself. Notes are just notes. Relax.
Comment: Thank you for the reassuring words, I have just spoken to the office again, I am probably in the clear. Marking is done and the paper came back fine (ie. no reported issues) according to them, they just need to review and final grades will be posted soon.
Answer:
Have I done the right thing so far?

Yes.  You reported it.

Is there anything else I should do?

No.
I remember once an issue where I moved into some campus housing.  There was a container left in my unit's storage shed that was attached to the back of the partment.  It turns out that the container was used motor oil.  As I toured the apartment, I let my tour guide know that I wasn't worried about it.  I didn't know what was in the container, and planned to throw it away.  But what really happened is that I never used that storage unit, and forgot all about it...
... until the weekend when I visited my family, and somehow (wind?) the container spilled.  Children from nearby apartments were playing in the liquid, so there was a massive clean-up operation.  I first learned about it when I unusually looked out the window of my sliding glass door and found a construction barrier placed there, and tape labelled "Do not cross", etc.
I was then getting billed for the massive clean-up effort.  To that, I objected.
The school ended up taking my report and researching the issue by contacting the former apartment supervisor who was my tour guide, and learning that there was agreement that this oil originated from a previous tenant.  Although it took a couple of agonizing weeks to get an answer, they decided to not charge me.

The office told me I would not likely get in trouble

This is probably the best you're going to get.  I mean, it'd be even better to have that in writing.  But getting that in writing seems rather unlikely to me.  So, you'll just need to hope for the best, knowing that usually such statements made by staff are accurate, and even if they aren't, usually (but not always) an organization will decide to honor such statements if they are validated by the person who said that.

but I still have worries as marking is ongoing.

You can likely feel even more comfortable once your final grades are provided to you.  At that point, a school can likely still change your grades in the event of a situation that they consider extreme (and they may take any incident of "cheating" as being sufficiently extreme), but you're usually okay at that point.
I know, that's three times where I emphasized the word usually.  Sometimes, life offers you no absolutes, despite how much you might want one.  Knowing the usual results is, sometimes, simply the best you can get.
Comment: IMO you were lucky to win that one. Even though you had proof that the oil had been "inherited" from a previous owner, it became yours, and it remained stored, by you, in a container to which only you had access, and insufficiently safely at that, which then put children at risk. You should have dealt with it straight away. "Someone else possessed a thing before me" is no excuse for negligence.
Comment: @LightnessRaceswithMonica : I didn't use the storage unit (so it was unlocked) and plum forgot about that container until the incident.  The thought had never occurred to me that it might be hazardous material.  I question whether the "damage" was worth the excessive clean-up (they dug a ditch).  But all in all, I'm not disagreeing with the core of your statement: Perhaps the only reason I "won" was just me receiving some undeserved mercy.  (Even if so, I don't think that alters the answer, as written.)
Comment: Yep I think so too (No, just a tangent, though it does suggest the analogy doesn't really hold up)
Comment: The analogy is about waiting for the decision from a school's staff, and communication from the staff.  Even silence, aggravating as it may feel, can be the path towards ultimately desirable outcome.
Comment: Thank you again for your advice, the office told me again everything should be fine as they have had no reports of issues with my paper and marks have been completed.


World economy and world trade

Question: What is the difference between the world economy and world trade? I have read in one book saying "US share in the world economy is 28% and in the world trade is 15%" (2008 edition though). Please explain. Thanks
Comment: Trade is between countries as pointed out in the answer below. An easy way to distinguish between this and world economy is to think of the world economy as the total output produced by all countries. So 28% of the GDP of Earth is attributable to the U.S.
Answer: "Trade", in economics, usually means trade between countries.  So if goods made in, say, the Netherlands are sold in Belgium, that counts as trade.  But if goods made in, say, California are sold in Florida, that doesn't count as trade.  Because the US is a large and populous country, it has a high proportion of internal transactions that count as part of its GDP, a measure of its economy, but do not count as trade.  Many smaller countries, on the other hand, will have a share of world trade exceeding their share of the world economy.
Comment: Also, the definition of world trade is unclear. The fraction of a country in world trade could be with respect to imports, exports, or their average.
Comment: "Trade" is usually imports + exports.

World economy and world trade


What is the relationship between how time is viewed in thermodynamics and how time is viewed in general relativity?

Question: From my limited understanding of physics, it seems that the second law of thermodynamics, in which entropy never decreases over time in a closed system, relates to how time can only go forward i.e. the arrow of time. Additionally, general relativity highlights that space, time, and gravity are deeply intertwined i.e. gravity is curvature of space-time. What is unclear to me is how these different perspectives on time are related, hence the question.
Comment: Thermodynamics tells us what direction time "flows". Relativity tell us how the rate of this flow depends on relative reference frames. What type of relationship are you looking for here, or why do you think this relationship should even exist?
Answer: Time for us was defined by the natural clocks of the seasons and the day night repetitions. If you look at the history of  time even the the units were variable in some civilizations.

In classical Greek and Roman times they used twelve hours from sunrise to sunset; but since summer days and winter nights are longer than winter days and summer nights, the lengths of the hours varied throughout the year.
Hours did not have a fixed length until the Greeks decided they needed such a system for theoretical calculations. Hipparchus proposed dividing the day equally into 24 hours which came to be known as equinoctial hours. They are based on 12 hours of daylight and 12 hours of darkness on the days of the Equinoxes. However, ordinary people continued to use seasonally varying hours for a long time. Only with the advent of mechanical clocks in Europe in the 14th Century, did the system we use today become commonly accepted.

These units were locally  in use in the middle east afaik until the beginningof last century, where night and day were divided by twelve between sunset and sunrise. They are still used for religious purposes afaik.
There is a history of mechanical clocks, and then came the atomic and quantum mechanical revolution and the atomic clocks which can define the unit of time within any system having that atom.
In parallel, physics defined the arrow of time thermodynamically, by the change in entropy , and that is the arrow of time we use on the axis of time to define a $+$ and
a $-$ .
We transfer this arrow of time to special relativity, and have an enormous number of data to know that it works without mathematical contradictions, and to general relativity. We are creatures dominated by classical thermodynamics. In science fiction one might find other frames of reference, but that is the fact, that our "coordinate" base is in classical dimensions.
You ask:

What is unclear to me is how these different perspectives on time are related, hence the question

Even for the  $(x,y,z)$  coordinates special and general relativity introduce distortions with respect to different kinematic frames, but they do not change the meaning of $+$ and $-$ for a relativistic transformation. It is just that our existence works one way by thermodynamic laws that the $-$ of time is inaccessible and an arrow has to be defined for the history of the universe.
There are no different perspectives, but expanded views keeping the same definition for the arrow of time from classical mechanics to relativistic, where coordinates acquire different behaviors, but the arrow of time is fixed by the fact of our physical existence in the classical realm.
Answer: In thermodynamics, the way time is viewed is connected in some ways to entropy. The second law of thermodynamics states that the entropy of an isolated system never decreases.
Such systems spontaneously evolve towards thermal equilibrium. This will give an arrow of time in the view of thermodynamics.
For us, it is natural to look at macro objects to evolve chemically the way they do, because we are used to it. But the reality is that this second law of thermodynamics is what dictates the evolution of the macro systems that we observe in our life. Chemical reactions in a macro system obey the second law of thermodynamics, and so we tend to be used to viewing these macro systems to chemically evolve the way they do. This thermodynamical and chemical law will give an arrow to time in our lives. We are used to it, because that is how everything we view evolves in the macro world.
Now GR will explain you that if you place two clocks in two different gravitational zones, they (as the gravitational potential will be different at the two clocks' position), the clocks will tick differently when viewed from afar.
If you look at your own clock locally, it will always tick normally. It is when you compare your clock to another clock that is in another gravitational field (that has a different gravitational potential) when you will see that the clocks tick at different rates. A very good way to learn about this is the Shapiro delay.
Now you are asking how these different ways of viewing time are connected. You are basically asking whether there is casuality between GR time dilation and the laws of thermodynamics.
Let's take a very strange example.

Let's assume that GR time dilation causes the laws of thermodynamics.

This would mean that the gravitational potential, and the difference between the gravitational potential (between different places in space) causes the laws of thermodynamics. Let's say that the earth is an isolated system and it is moving towards thermal equilibrium. Is this second law of thermodynamics caused by GR time dilation? Is this caused by the fact that the gravitational potential will dictate how fast time will flow on earth (compared to another place in space where the gravitational potential is different)? No it does not.
The laws of thermodynamics are based on QM processes. There is no way how we could say that entropy is caused by GR time dilation.

Now let's try the opposite, let's say that GR time dilation is caused by the laws of thermodynamics.

This would mean that there is a way we can prove that, the laws of thermodynamics, which is based on QM processes, cause GR time dilation. So basically QM processes cause the gravitational potential, and the difference between the gravitational potential to cause time to flow at different rates at different points in space (where the gravitational potential is different). To prove this, we would need to prove that the gravitational potential is determined by QM processes. This would be quantum gravity. As of today, we have no accepted theory of everything (TOE), that would include GR and QM, and that could explain both on the QM level. There are theories like string theory, that could be like that, but they need to be experimentally tested and proven.
To answer your question, to say (or even to think about) that the gravitational potential (and gravitational effects) is caused by the same QM processes that cause the laws of thermodynamics, we would need first of all a QM level description of GR, and a TOE.
Comment: "1. Let's assume that GR time dilation is caused by the laws of thermodynamics. " "2.Now let's try the opposite, let's say that GR time dilation is caused by the laws of thermodynamics. "  It is not the opposite, it is the exact same assumption. Is there a mistake you should edit?
Comment: @coniferous_smellerULPBG-W8ZgjR correct, thank you edited 1.


Why could Yvonne Hartman attack the other Cybermen?

Question: In "Doomsday" Yvonne becomes a Cyberman and presumably loses all emotion and sense of personal identity. Yet, she resists their control at the end, and kills her own "kind." How? What makes her so special from the thousands of Cybermen before her? As far as I know, no one else has ever been able to assert control once they've been transformed.
Comment: [Lazy Writing](http://tvtropes.org/pmwiki/pmwiki.php/Main/DeusExMachina)?
Answer: Closing Time is another episode where someone defeats the mind control of the Cybermen. As well as that Cyberwoman in the Torchwood episode Cyberwoman (Season 1 Episode 4). It seems as if there is a strong enough emotion (or the process didn't complete for some reason) the person will get over the Cyber control.
Comment: S08E12, "Death In Heaven", shows multiple characters with strong emotional attachments overriding their Cyberman psyche.  In one of the cases, it's implied that the character had not completed his emotional purging process, but there's no indication the other character hadn't been fully processed prior to overriding the Cyber control.


OData query to get the results of two specific columns

Question: I stuck on how to get two specific columns of data. My query:
{site}/_api/web/lists('{site_guid}')/items?$select&fields eq meatballColor,meatballExplained

I only get 7 items coming back when it should be 14, wondering if my syntax is correct.
Answer: TL;DR
The correct syntax for a $select that returns only column values from two columns (using your example for column names) is:
{site}/_api/web/lists('{list_guid}')/items?$select=meatballColor,meatballExplained

but that is still going to return all the items in the list, which according to your screen shot looks like 7.

First, from the screenshot of the list that you provided, it looks like there are only 7 items in the list.  So when you say

I only get 7 items coming back when it should be 14

If you are thinking that you should be getting 14 results because there are 7 list items but you are asking for 2 column values, so you are expecting 7 x 2 = 14 things, that's not how the results are going to come back.
You can use a $select in your oData query to limit the number of columns returned, but they are still going to be divided into separate objects that correlate to the list items that hold those values in those columns.  If you want to limit the number of overall items that get returned, you would need to use a $filter in order to only return the list items that match your specific criteria.
For instance, if you did a query on that list with no $select to restrict the columns:
{site}/_api/web/lists('{list_guid}')/items

you would get a result that looked something like this (although with a lot more fields/columns included, because there are a bunch of built-in hidden SharePoint fields):
{
    d: {
        results: [
            {                // <-- first list item object
                Title: "y",
                default: "up",
                meatballExplained: "Choice #1",
                meatballColor: "Green",
                // other built-in SP fields
            },
            {                // <-- second list item object
                Title: "u",
                default: "down",
                meatballExplained: "Choice #3",
                meatballColor: "Red",
                // other built-in SP fields
            },
            // and then the other 5 list item objects here
        ]
    }
}

Now, if you used a $select to limit the fields, you're still going to get a results array of 7 items, because you are not using a $filter to limit the number of items, however, you would see less data inside each list item object.
Your $select query is also not quite the right syntax.  Instead of
/items?$select&fields eq meatballColor,meatballExplained

what you want is
/items?$select=columnOneName,columnTwoName

so in your specific case
{site}/_api/web/lists('{list_guid}')/items?$select=meatballColor,meatballExplained

And the result you get from that will look something like
{
    d: {
        results: [
            {                // <-- first list item object
                meatballExplained: "Choice #1",
                meatballColor: "Green"
            },
            {                // <-- second list item object
                meatballExplained: "Choice #3",
                meatballColor: "Red"
            },
            // and then 5 more list item objects here
        ]
    }
}

Notice that Title and default are no longer included (since they are not part of the $select), but you still are going to get all 7 list items.
Now, if you used a $filter to limit the number of items based on certain criteria, you could do something like
{site}/_api/web/lists('{list_guid}')/items?$select=meatballColor,meatballExplained&$filter=meatballColor eq 'Yellow'

which is telling SharePoint "give me all the list items where meatballColor is Yellow (but not any others), but only give me the values of meatballColor and meatballExplained for those few list items."
What you would get would look something like
{
    d: {
        results: [    // <-- the 'results' array will only contain 2 items, not all 7
            {
                meatballExplained: "Choice #3",
                meatballColor: "Yellow"
            },
            {
                meatballExplained: "Choice #5",
                meatballColor: "Yellow"
            }
        ]
    }
}


how to use ldap_sasl_bind_s() with SSL, DN, password (no client cert)

Question: I have ldap_sasl_bind_s() working fine with SSL and client cert (without DN and password) from 'C' windows program.
When I call ldap_sasl_bind_s() using SSL, DN and password (no client cert) it throws null pointer exception. Should this work or should I be using another api call?
Answer: I found the answer in the Sun LDAP SDK doc. Even if the client is not using client cert auth, it still needs to pass the cert7 database file on the previous ldapssl_client_init() call as the client verifies the server cert was signed by the cacert defined in the cert7 db.


Are most commercial satellites communication satellites?

Question: Is it true that commercial communications satellites account for the largest share of commercially used satellites?
Answer:
Is it true that commercial communications satellites account for the largest share of commercially used satellites?

Definitely, and this is becoming even more true with the advent of constellations such as Starlink. In addition to those low Earth orbit communications satellites, the vast majority of the satellites in geosynchronous orbit are communications satellites.
Many of the other satellites that do have commercial application are the civilian equivalent of spy satellites. While there certainly is a commercial demand for that usage, those satellites are expensive and there is no need for continuous coverage.
A third commercial application is the medium Earth orbit set of global navigation satellites such as GPS. Once again, the number of satellites needed for that purpose is limited.
Comment: Where do weather satellites fit in your taxonomy?
Comment: @Barmar Those are Earth observation satellites, which are conceptually much closer to spy satellites than communications satellites. There are even commercial Earth observation satellites that are not used for observing the weather. Those non-meteorological commercial Earth observation satellites sometimes even have a dual use as spy satellites. There not that many of them.


Why do I get the message "device connection disrupted" when I connect my phone to the computer?

Question: I have a Samsung Galaxy mini gt-55570. When I try connecting my phone to the computer, I get the message "device connection disrupted" and " Kies has stopped working". What is the problem and how can I fix it?
Answer: If you have an SD card in your phone try, removing it first and try again. If it works, then good.


Why would I want a custom Docker host VM instead of TinyCore Linux in boot2docker?

Question: I've read about Docker, boot2docker and Vagrant's Docker provider and I guess I have a pretty firm grasp of how all of this works. However, there is still one thing I haven't quite figured out yet.
Docker Host VMs (like TCL in boot2docker) provide a "proxy" VM environment to allow us to use Docker on non-Linux hosts. Now, say, if I want to reproduce a certain production environment, does it really matter which Docker Host VM I actually use? Why would there be a demand to choose a different host VM?
The reasoning here is that I can simply derive services like httpd and mysql FROM the desired boxes, i.e. if I use boot2docker and my production environment runs Ubuntu 14.04, I can simply "extend" the Ubuntu image in my Dockerfile and be done with it.
Am I right in thinking that switching the Docker Host VM would only be desirable while reproducing a production environment which also makes use of the Docker technologies? My particular use case involves using Docker (and Vagrant, too) only for isolation purposes in my own development environment. This may be the reason why I pretty much missed the point of a custom host VM.
As I understand, using Vagrant with Docker is just another level of abstraction to create a persistent and portable development environment. However, having in mind that it is possible to force Vagrant to use a particular host VM even on Linux hosts, I guess that there is some significance in using a custom host machine, but I am not yet aware of it.
Answer: It's a matter of balance. The simpler and smaller a hosts footprint is, the safer and probably more efficient and resource-friendly it'll be.
For management of a host or cluster of hosts you'll want tools, so you need to add those (assuming the tools are needed before and/or outside of containers) which then bloats the host OS.
In short, people have different opinions on what a host OS should provide and these opinions are what should guide you in your choice of host OS.
an article with example opinions on the matter: https://blog.docker.com/2015/02/the-new-minimalist-operating-systems/


ASP.NET hidden field vs. invisible textbox

Question: what are benefits of using a hidden field in ASP.NET when we can use another invisible element such as label or text box?
Answer: The hidden field generate <input type="hidden" /> element on the page, which cannot be seen but the client can get the element, set the data and pass to the server:
document.getElementById('<%= SomeHiddenField.ClientID %>').value = "data_pass_to_server";

after postback you can get the value:
var clientData = SomeHiddenField.Value; // "data_pass_to_server"

If you're using invisible textbox (<asp:TextBox Visible="False" />), there's no element generated in the html file.
Answer: Either way works, for text box, don't use .visible="false"
use
yourTextBox.Style.Add("display", "none")

or
yourTextBox.Style.Add("visibility", "hidden")

Answer: A hidden field renders as input type="hidden" in the resulting HTML. Being an input the value in the input is submitted to the server on postback while this is not the case with a label. Depending on whether or not you want that value submitted to the server you should use input or label. If you don't want the value to be submitted then label is the right solution and hidden field is wrong.
I am not sure what you mean by invisible textbox but if you are trying to make it invisible via CSS keep in mind that the input type has semantic meaning to search engines, bots, etc. Also at some point your HTML might be served without CSS or with different CSS and the text box will become visible to the user. Otherwise there are no differences between hidden field and invisible text box as both of them render inputs.
Answer: Practically you can achieve the same thing with any of them, but since you want a "hidden field", semantically speaking the hidden field in ASP.NET is your best bet for readability reasons.


How can I remove the smell of egg from my hands?

Question: Whenever I baked something like cake and used eggs in this, the smell of egg remains on my hand even after I washed my hand, which irritates me a lot. What could be remedies to remove this smell quickly?
Comment: I never experienced the effect you describe (and I bake and cook *a lot*). What kind of eggs are you using and how are you storing them? How do you get egg on your hands in the first place and how much?
Comment: when I put it over baking plate and also when mixing it with baking material
Comment: ofcourse i also used hen's eggs.
Comment: @banneenbeno As opposed to rooster eggs? :P
Answer: I use the juice of a lemon to remove smells from my hands after eating crab.  It might work for eggs, too.
Answer: I think toothpaste is the best for removing any type of smell from hands.it is quickly solution for best results .take some toothpaste and apply on your hands ,wait for two minutes then wash it.


Intuition on variance of linear combination of variables

Question: I have the formulas for the variance of linear combintion of variables given as $$
\text{Var}\Bigl(\,\sum_{i=1}^n X_i\,\Bigr)=  \sum_{i=1}^n\text{Var}( X_i)+
 2\sum_{i< j} \text{Cov}(X_i,X_j).
$$
I know this is derived from variance of 2 variables and extrapolation. However, what is the intuition behind this formula? Can someone explain further on how I could  use this formula to understand covariance better?
Answer: Other answers have addressed derivation, but you asked for intuition:
Variance is a measure of uncertainty. The higher the variance the greater the uncertainty. Uncertainty is additive. If $X_1$ and $X_2$ are uncorrelated, the uncertainty in their sum is the sum of their uncertainties: $Var(X_1 + X_2) = Var(X_1) + Var(X_2)$. But what if they are correlated? Two things can happen. If they are positively correlated this will increase the uncertainty since this makes it more likely that observations of the two variables will pull away from the means in the same direction, pulling the sum even farther away from its mean. On the other hand, if they are negatively correlated, they will tend to pull in opposite directions with larger than average observations of one variable tending to be offset by smaller than average observations of the other. This will lead to a cancellation of errors whereby the sum will be even closer to its average than either of the variables are close to theirs. The covariance term $Cov(X_1,X_2)$ shows how the correlation between the variables effects the overall uncertainty. Similar intuitions hold with more than 2 variables. Every pair of variables $X_i,X_j$ can either increase or decrease the overall uncertainty of the sum. By adding all such covariances together you get the net change of uncertainty from all such pairs.
Intuitions are not theorems. The above paragraph doesn't apply to all cases. For example, one way that you could have $Cov(X_1,X_2) > 0$ is by having a large number of negative values be offset by rarer but larger positive values. $X_1$ and $X_2$ might actually tend to pull in opposite directions in the sense that $P((X_1 - \mu_1)(X_2 - \mu_2) < 0) > 0.5$ but nevertheless $Cov(X_1,X_2) > 0$ since when they pull in the same direction they really pull in the same direction. The formula itself takes all such considerations into account.
Comment: This should be the accepted answer
Comment: @SK19: (a) The OP probably knows what he finds more intuitive than we do, (b) I actually found the accepted answer more intuitive to be honest... it explains where the $2$ comes from.
Answer: This formula is actually not at all deep and works if you replace $\mathrm{Cov}$ with any symmetric bilinear form. Imagine we have an inner product $(-,-)$ and we want to find $(a+b,a+b)$. Then
$$(a+b,a+b)=(a,a)+(b,b)+(a,b)+(b,a)=(a,a)+(b,b)+2(a,b)$$
You can find a similar formula for $(a+b+c,a+b+c)$, and the general form is exactly the same. It just depends on covariance being symmetric and bilinear and the variance of a variable being the covariance with itself.
Answer: It is very simple. It is just like opening up brackets in a $(a+b)^2$. In that case you will have $a^2+2ab+b^2$.
Hopefully that can guide you to figure out how it's derived. Let me know if you need in depth explanation though.
Answer: If you use the formulas $$\text{Var}(X) = E[X^2]-E[X]^2$$ and $$\text{Cov}(X,Y) = E[XY] - E[X]E[Y]$$
using the properties of expected value you can derive the formula easily.
It might also help to see variance as a special case of covariance:
$$\text{Var}(X) = \text{Cov}(X,X)$$ so we see $\text{Var}(X_i)$ is a simplified form of $\text{Cov}(X_i,X_i)$, matching the covariance sum.


Turn windows server to evaluation mode

Question: Is there a way to turn a copy of windows server to evaluation?
Reason is that I have a virtual machine which has a few softwares installed on it (which unfortunately cant be installed in an automated fashion), and would like to turn it to evaluation use.
Windows server 2008
Answer: slmgr /upk or slmgr -upk uninstalls product keys from that installation of Windows.
Comment: Thanks. So i'll need to then get a product key for evaluation purposes or let the person who gets the system worry about it!
Also thanks for marking down the question :)

Turn windows server to evaluation mode


In Bayesian networks, what does it mean a node is "instantiated"

Question: i am trying to follow these slides on bayesian networks.
Can anybody explain me what it means that a node in a bayesian network is "instantiated"?
Answer: It means the node is created. Spawned. Brought to existence. If B isn't represented by an instance (roughly: does not exist), then the path is different than if B exists (is instantiated).
You can get evidence either by instantiating a node (in which case its truth value is known) or by arriving to this node from some other node. So either the node is instantiated and you get evidence from its truth value, or it is not and you get evidence from the flow.
Comment: @user1291235 You can get evidence either by instantiating a node (in which case its truth value is known) or by arriving to this node from some other node. So either the node is instantiated and you get evidence from its truth value, or it is not and you get evidence by the flow. So the difference is in the way you get the evidence.
Comment: so then what is the difference between "a node is instantiated" and "a node gives evidence". does it mean that the latter one was instantiated before?
Answer: Instantiating a node in Bayesian networks is different from object oriented programming. A node is instantiated when it's value is known through observing what it represents. If it is not instantiated then it's value can be updated through Bayesian inference.
In the example A -> B -> C. Assuming nodes are boolean (either true or false) then if you instantiate C (e.g. C = true) then the values of B and A will update using Bayesian inference. However, if B is also instantiated then it d-separates A and C, so instantiating C will not update A. The rules of d-separation depend on the type of node configuration, so that instantiating a node may either d-separate or d-connect nodes.


Are there trackers that work even for people who are using extensions like Privacy Badger?

Question: If so, what are they and how do they work?
(This is within the context of a blog. I do not have access to the server).
Answer: That is in theory possible. Privacy Badger monitors all the domains that are consulted when you fetch a webpage and then looks for third party domains (Domains that arent equal to the domain of the website you entered) that apear on many different sites asuming that these are trackers or ads. Of cause there must be a whitelist for google code and so on... but basicly that is how this plugin works.
When one creates a tracker that is divided over a huge load of domains and uses them in a round robin way it might be possible that it is not or just after a very long time detected and blocked by Privacy Bager. Indeed this can only work if they change their domains constantly because they otherwise could be blocked by simple blacklisting. Like I said its theoretically possible...
Answer: The simplest way of tracking someone with Privacy Badger being none the wiser would be by sharing some specific access logs.
For example consider any popular Javascript library hosted on a distributed cloud system. You might have several sites that use jQuery, or Bootstrap, or Angular, or any other popular library.
When you request a resource from that site, you almost always will do so by sending a If-Modified-Since or If-None-Match token, and those can be tailored to allow reliable-enough identification just as if they were cookie tags. And they are requested together with a nifty Referrer header too.
At that point the "shared content" site is in a unique position to track you without resorting to cookies or anything else, which would supply one possible answer to the question "why do these people offer content hosting for free?"