Will God ever forgive me for taking my cousin's virginity?

Question: I've made a really bad mistake and I know it. I don't know if Allah will forgive me. I'm a girl and my cousin is also a girl, and I took her virginity and I feel like dying because I know what I did was wrong, and after I done that I really hope God will forgive me.  Will He ever forgive me?  What do I have to do to have his forgiveness? Please don't judge me, I've learned from my mistake and I will never do anything like that ever again.
Comment: I'm voting to close this question as off-topic because its opinion based. Will Allah forgive you? How are we supposed to know? That is His decision. Allah does forgive sins when a person sincerely repents. See [Quran 39:53](https://quran.com/39/53) and [4:48](https://quran.com/4/48) and  [42:25](https://quran.com/42/25)
Answer: Allah says:

"Say: O my Servants who have transgressed against their souls! Despair
  not of the Mercy of Allah: for Allah forgives all sins: for He is
  Oft-Forgiving, Most Merciful." [Sûrah al-Zumar: 53]
25:68-69 "And those who invoke not any other ilah (god) along
  with Allah, nor kill such a person as Allah has forbidden, except for
  just cause, nor commit illegal sexual intercourse and whoever does
  this shall receive the punishment.The torment will be doubled for him
  on the Day of Resurrection, and he will abide therein in disgrace;
25:70 Except those who repent and believe (in Islamic
  Monotheism), and do righteous deeds; for those, Allah will change
  their sins into good deeds, and Allah is Oft‑Forgiving, Most
  Merciful."

Based on these verses, no sin is too great for Allah to forgive for the one who repents.
This Hadith also clarifies it.

Al-Tirmidhi narrated that Anas ibn Malik (may Allah be pleased with
  him) said: I heard the Messenger of Allah (peace and blessings of
  Allah be upon him) say:
"Allah, may He be blessed and exalted, said:
" O son of Adam, so long as you call upon Me and ask of Me,    I shall
  forgive you for what you have done, and I shall not mind.    O son of
  Adam, were your sins to reach the clouds of the sky and were you then
  to ask forgiveness of Me, I would forgive you and I would not mind. "
[Saheeh al-Tirmidhi]

So Allah will forgive your sins if your repent sincerely and do good for taking away your sins.


Master degree in 2 countries?

Question: I am looking for international master degrees which are offered in 2 different countries. For example first year in Singapore and second year in Brasil. How can I find such universities or programs? Is there a big database for such schools?
Answer: Such programs are rare enough that I don't know any. I would look into universities that have campuses in multiple countries, and if they allow you to transfer campuses during the program or something along those lines. That would allow you to get the same effect without there being a specific program for it.
Answer: One option is to look at the Erasmus Mundus joint masters degrees (current list here). I did one of these a few years ago, spending one year in Sweden and one year in Germany, but I think that some of the programmes include at least one year outside of Europe. They also offer a number of full scholarships for some (all?) programmes. In my case, this was a great experience both academically and culturally.
Comment: Thanks I live in Europe and I have been to almost all EU countries and would like to see and study in oversea countries.
Answer: You can see if the university has an exchange program with another university. If so, then you could possibly split time between two universities, but it may not be a 50-50 split.

Master degree in 2 countries?


How to fix install updates message, even though there are no updates to install?

Question: I have Ubuntu 16.04 and when I go to into my settings into the Details/Overview page I see a button on the bottom right that says: "Install Updates". Pressing it gives a small progress windows, that does not really install anything new. How can I change the button to display system up to date, instead of doing this pseudo update nothing thing?
Comment: Possible duplicate of ["The following packages have been kept back:" Why and how do I solve it?](https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it)
Answer: The main problem is that the GUI does not show the error message from the terminal, which in my case was: "The following packages have been kept back:" Then following the answers from here should work to fix it.
Answer: Install Updates option
When you select System Settings, Details your screen looks like this:

The lower right option "Install Updates" could best be described as:

Check if updates exist and then give me option to install them

Terminal equivalent
To mimic the steps in the terminal the first step is to update repository information similar to sudo apt update:
$ sudo apt update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Ign:2 http://archive.canonical.com/ubuntu trusty InRelease
Ign:3 http://dl.google.com/linux/earth/deb stable InRelease
Hit:4 http://dl.google.com/linux/chrome/deb stable Release
Hit:5 http://archive.canonical.com/ubuntu trusty Release
Hit:6 http://dl.google.com/linux/earth/deb stable Release
Hit:9 http://security.ubuntu.com/ubuntu xenial-security InRelease
Ign:11 http://ppa.launchpad.net/daniel.pavel/solaar/ubuntu xenial InRelease
Hit:12 http://ca.archive.ubuntu.com/ubuntu xenial InRelease
Hit:13 http://ca.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:14 http://ppa.launchpad.net/fossfreedom/indicator-sysmonitor/ubuntu xenial InRelease
Hit:15 http://ca.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:16 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu xenial InRelease
Hit:17 http://ppa.launchpad.net/mkusb/ppa/ubuntu xenial InRelease
Hit:18 http://ppa.launchpad.net/peek-developers/stable/ubuntu xenial InRelease
Hit:19 https://download.01.org/gfx/ubuntu/16.04/main xenial InRelease
Hit:20 http://ppa.launchpad.net/peterlevi/ppa/ubuntu xenial InRelease
Hit:21 http://ppa.launchpad.net/sethj/silentcast/ubuntu xenial InRelease
Err:22 http://ppa.launchpad.net/daniel.pavel/solaar/ubuntu xenial Release
  404  Not Found
Reading package lists... Done
W: https://download.01.org/gfx/ubuntu/16.04/main/dists/xenial/InRelease: Signature by key 09D6EF97BFB38E916EF060E756A3DEF863961D39 uses weak digest algorithm (SHA1)
E: The repository 'http://ppa.launchpad.net/daniel.pavel/solaar/ubuntu xenial Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Next to see what packages would be updated use:
$ sudo apt list --upgradeable
Listing... Done
conky-std/xenial 1.10.1-3 amd64 [upgradable from: 1.9.0-4]
libpoppler-glib8/xenial-updates,xenial-security 0.41.0-0ubuntu1.6 amd64 [upgradable from: 0.41.0-0ubuntu1.5]
libpoppler58/xenial-updates,xenial-security 0.41.0-0ubuntu1.6 amd64 [upgradable from: 0.41.0-0ubuntu1.5]
poppler-utils/xenial-updates,xenial-security 0.41.0-0ubuntu1.6 amd64 [upgradable from: 0.41.0-0ubuntu1.5]

In this case the much awaited Meltdown security hole patch is probably available to install which would be accomplished with sudo apt upgrade. But I'm going to hold off until others have installed it and tested it.
Summary
The option on the Details screen is designed to check if updates exist when you click the button. To have it check for updates before mounting the screen and changing the button to "System up to date" or "Install Updates", would provide a delay of many seconds to a minute. A third button label of "Internet unavailable" would also have to be created.
I don't think the change you are seeking is possible for the System Details screen.

Update - Errors in packages
OP posted answer that some packages are being held back. This can happen frequently for a variety of reasons:

Dependencies: Package depends on another package being updated but in cannot be.
Pinned: A package (such as Conky 1.9 above) has been pinned to a specific version by user and can't be upgraded by Ubuntu.

You can see these messages when you use sudo apt upgrade from the terminal but OP did not see these messages through GUI.
Comment: There are indeed two packages that need updating on my system, 2 cuda drivers. But sudo apt upgrade/update both don't upgrade the two packages. How can it be that they get listed in apt list --upgradeable, but can not be upgradet?
Comment: nvm, this answers it: https://askubuntu.com/questions/601/the-following-packages-have-been-kept-back-why-and-how-do-i-solve-it
Answer: Just install updated using any one of the following methods.
method 1 (GUI):
search  'Software Updater' in unity search bar then select 'install now' once its queries all updated.
method 2 (CLI):
$ sudo apt-get update
$ sudo apt-get upgrade -y
$ sudo apt-get install -f -y

Note: make sure that you have an uninterrupted internet connection.


Why would you use 'custom attributes' in your code (.NET)

Question: Could anyone explain the benefits (or reasons) to use custom attributes in your code. Of course I use (and understand the purpose of) defined attributes in certain scenarios (WCF, Serialization etc.), but I cannot imagine any algorithms where I would need to create and use my own custom attributes. Could someone provide a real-world case where usages of custom defined attributes bring something to a project.
Answer: The same reason as for WCF etc, but something that's specific to your project - you want to add some metadata to some members (types, fields, methods, whatever) to specify something about the mechanism involved, and it's not something which is covered by existing attributes.
For example, NUnit wanted to add their own indication that a particular type contained unit tests - there was no such existing attribute, so they created TestFixtureAttribute.
It's a relatively rare event, sure - but it can happen.
Answer: If you want to write your own system like WCF, Serialization, etc...
If you write code that iterates over types or members and does things with them, you will frequently want to use your own custom attributes to mark some members as being different or special.
Answer: I regularly use custom .Net attributes to support tooling in my infrastructure.  One example was from very early in the .Net days (C# 1.0 to be exact).  I was working on a research project which had a native C++ front and a brand new C# back end written by yours truly.
The front and back end shared a very similar object model which was evolving very rapidly.  Not wanting to have to hand code both a C++ front end model, C++ serialization mechanism and a C# serialization mechanism I chose instead to attribute my C# types with custom attributes.  They told me the parts of the model which were shared between the front and back end.
Once those attributes were in place I wrote a quick and dirty tool which

Parsed out the attributes to construct the core shared model
Generated the C# serialization code
Generated the C++ code
Generated the C++ serialization code

This made it dirt simple to keep my model up to date between my 2 projects.  Just change the C# code, compile and re-run my tool.
Answer: I have used annotations in a custom AOP (Aspect-Oriented Programming) system I developed a while back.  Attributes are also very useful for controlling orthogonal concerns like code generation.
Answer: They can be used for marking tests, as in MBUnit for example. They can also be useful for code that inspects and loads classes (like a Plugin system) to provide meta-information.
Answer: Custom validation is a very good use case and can be seen from these links:
http://odetocode.com/blogs/scott/archive/2011/02/21/custom-data-annotation-validator-part-i-server-code.aspx
How to create Custom Data Annotation Validators
Answer: They are really useful in building object mappers / ORM tools as well.  If you ever decide to roll your own mapping system they are almost "required" to get all the functionality one would need.  It's used more for making methods / classes more generic and using reflection to determine how to handle objects / select objects /etc...
Answer: To give you a specific case where I've used them. I once had to interact with a Mainframe screenscraper.  I created a custom attribute to annotate which fields I wanted to send from my classes to the Mainframe, names that fell outside of conventions, special rules to deal with formatting and collections. I then had a class which was able to reflect over instances and realise which subset of fields were needed to interact with the mainframe screen scraper appropriately.


Extracting the code from Keras

Question: Suppose I write a program in Keras for MNIST data set. I used TensorFlow as my backend in Keras. Is it possible in any way that I can extract the backend code used for TensorFlow that has been used by Keras. if yes, please provide an example.
Answer: If you are looking for a way to compile code written for the Keras API to code only using the Tensorflow API, there is no ready-to-use solution for that. And I cannot see any good reason why someone would want to do that in the first place...
You can simply look at the Keras backend source code for Tensorflow and rewrite your entire implementation. But once again I don't see any valid reason that would make this worth it.
Comment: It *might* be worthwhile for deployment. It removes Keras as a dependency on production systems for instance. You would use Keras as a quick way to build and prototype different networks, then discard it for pure TensorFlow version once you had found your ideal network. However, I agree in that I don't think there's much to gain in terms of performance or deployment effort between Keras+TensorFlow vs just TensorFlow (although in older versions there was, Keras did not use TensorFlow efficiently). It is not a huge effort to build a network natively in TensorFlow anyway.

Extracting the code from Keras


File upload using Form POST?

Question: Is it possible to upload a file to SharePoint using a simple HTML form POST and if so, where does the file end up?
<form action="..." method="post" enctype="multipart/form-data">
    <input type="file" name="myUploadInput" />
    ...
</form>

Answer: If you mean to upload file from local folder to document library than follow this method

Create an application page in Microsoft Visual Studio 2010, , as described in Creating Application Pages for SharePoint.
Add an HtmlInputFile control, a text box, a button to the form, and an FormDigest control to the page.
 <form id="Form1" method="post" runat="server">
   <SharePoint:FormDigest runat="server" />
   <input id="File1" type="file" runat="server" title="upldFileBox">
   <asp:Button id="Button1" runat="server" Text="Upload File"></asp:Button>
   <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
 </form>

In the .aspx.cs code-behind file, add using directives for the System.IO and Microsoft.SharePoint namespaces, as follows.
 using System.IO;
 using Microsoft.SharePoint;

Add the following code to the Click event for the button.
if (File1.PostedFile == null)
  return;

string destUrl = TextBox1.Text;

SPWeb site = new SPSite(destUrl).OpenWeb();

Stream fStream = File1.PostedFile.InputStream;
byte[] contents = new byte[fStream.Length];

fStream.Read(contents, 0, (int)fStream.Length);
fStream.Close();

EnsureParentFolder(site, destUrl);

site.Files.Add(destUrl, contents);

The value that you type in the text box for the destination must be an absolute URL, including the file name, which is assigned to the destUrl parameter.
In addition to instantiating an SPWeb object for the parent site, the combined use of the SPSite constructor and OpenWeb method validates the URL and throws an argument exception if the URL is not served by the current SharePoint Foundation deployment. A HtmlInputFile object is used to read the source file into a byte array for use with the Add method of the SPFileCollection class.
The example defines an EnsureParentFolder method to ensure that the parent folder in the destination URL exists in the specified site, and it returns the site-relative URL of the parent folder. The EnsureParentFolder method accepts two parameters: an SPWeb object that represents the parent site, and a string that contains the absolute URL that is passed from the example's UploadFile method. If the parent folder does not exist, the EnsureParentFolder method creates it.
public string EnsureParentFolder(SPWeb parentSite, string destinUrl)
{
 destinUrl = parentSite.GetFile(destinUrl).Url;

 int index = destinUrl.LastIndexOf("/");
 string parentFolderUrl = string.Empty;

 if (index > -1)
{
parentFolderUrl = destinUrl.Substring(0, index);

SPFolder parentFolder
    = parentSite.GetFolder(parentFolderUrl);

if (! parentFolder.Exists)
{
    SPFolder currentFolder = parentSite.RootFolder;

    foreach(string folder in parentFolderUrl.Split('/'))
    {
        currentFolder
            = currentFolder.SubFolders.Add(folder);
    }
}
}
  return parentFolderUrl;
}

The GetFile method of the SPWeb class is used in combination with the Url property of the SPFile class to convert the URL to a site-relative URL, throwing an exception if the specified URL is not found within the scope of the site. The URL of the parent folder is calculated by using the String.LastIndexOf method to determine the last appearance of a forward slash (/) within the destination URL. If there is no slash (in other words, the index equals -1), then the destination is the root folder for the site and the parentFolderUrl parameter returns an empty string. Otherwise, the example uses the GetFolder method of the SPWeb class to return the destination parent folder. If the folder does not exist, the example constructs the folder.
To upload a file from a local folder that is located on the same server that is running SharePoint Foundation, you can use a FileStream object instead. In this case, add a using directive for the System.IO namespace, in addition to directives for System and Microsoft.SharePoint. The following example uses the Click event handler to call a custom UploadFile method, which in turn calls the previously described EnsureParentFolder method.
 public void UploadFile(string srcUrl, string destUrl)
{
 if (! File.Exists(srcUrl))
{
  throw new ArgumentException(String.Format("{0} does not exist", srcUrl), srcUrl");
 }

  SPWeb site = new SPSite(destUrl).OpenWeb();

  FileStream fStream = File.OpenRead(srcUrl);
  byte[] contents = new byte[fStream.Length];
  fStream.Read(contents, 0, (int)fStream.Length);
  fStream.Close();

  EnsureParentFolder(site, destUrl);
  site.Files.Add(destUrl, contents);
 }

The UploadFile method accepts two parameters. The srcUrl parameter specifies the path of the source location in the file system of the local computer, and the destUrl parameter specifies the absolute URL of the destination. A FileStream object is used to read the source file into a byte array for use with the Add method of the SPFileCollection class.
Courtesy : http://msdn.microsoft.com/en-us/library/office/ms454491(v=office.14).aspx
Answer: Yes, you can upload files to SharePoint. It's built in to the system, and the file you're uploading will reside in the document library you uploaded to.

There is no need to develop a custom control for file uploading.
Comment: This does not answer my question
Comment: @Daniel from what I can read in your question, it answers the question very well. SharePoint is built on ASP.NET framework, which uses HTML technologies such as FORM action POST submission. In your questions current form I can't read that you want to make a custom uploading function. Nor can I read why you can't use out of the box funtionality. Thus I want to point you, and other, to the standard functionallity  of SharePoint.
Comment: Your answer doesn't tell me whether it's possible to upload an image using an HTML form POST. Which is what my question is. It's pretty obvious that this can be done using the OOTB UI, but that's not the question.
Answer: If you want to upload file using your own code but completely client side, follow this tutorial on MSDN:
http://msdn.microsoft.com/en-us/library/office/jj163201.aspx#BasicOps_FileTasks
function createFile(resultpanel) {
    var clientContext;
    var oWebsite;
    var oList;
    var fileCreateInfo;
    var fileContent;

    clientContext = new SP.ClientContext.get_current();
    oWebsite = clientContext.get_web();
    oList = oWebsite.get_lists().getByTitle("Shared Documents");

    fileCreateInfo = new SP.FileCreationInformation();
    fileCreateInfo.set_url("my new file.txt");
    fileCreateInfo.set_content(new SP.Base64EncodedByteArray());
    fileContent = "The content of my new file";

    for (var i = 0; i < fileContent.length; i++) {

        fileCreateInfo.get_content().append(fileContent.charCodeAt(i));
    }

    this.newFile = oList.get_rootFolder().get_files().add(fileCreateInfo);

    clientContext.load(this.newFile);
    clientContext.executeQueryAsync(
        Function.createDelegate(this, successHandler),
        Function.createDelegate(this, errorHandler)
    );

    function successHandler() {
        resultpanel.innerHTML =
            "Go to the " +
            "document library " +
            "to see your new file.";
    }

    function errorHandler() {
        resultpanel.innerHTML = "Request failed: " + arguments[1].get_message();
    }
}

Comment: James thanks for posting this... very helpful to know this can be done client side and to see an example... and with the help of HTML5 File API (as browsers move fowrad to fully supported ( ((cough)) IE), getting files from the user's computer and uploading them to SP will be possible.
Answer: Daniel,
I had this need a few years ago with a SP (2007) app I was developing and created a Widget that does it... It is meant to be used with an app that is hosted on a SharePoint site (not cross domain), and supports only uploading files to document libraries... I used it from a customized aspx page hosted inside a Document Library.
Its basically a wrapper around Sharepoint's Upload.aspx page which does some screen scrapping and manipulation in the background while only displaying a minimalist UI to the user.
Documentation here: http://purtuga.github.io/SPWidgets/ (look at the SPControlUpload widget).
Video of it in action: http://youtu.be/spOZsEtlUsQ
Hope you find a solution to your use case.
Paul.

File upload using Form POST?


How to handle categorical features in K-means?

Question: I am working on clustering algorithms. I am working with titanic dataset. It contains 6 categorical features. I used k-means algorithm on this dataset. I am using label encoding for categorical features. But I found that categorical features should use euclidean distance. It should use Hamming distance. So, how to make k-means work finely on mixed features? I don't need other algorithm. I just want to work with k-means only on mixed features dataset.
Comment: You should use one-hot enconding rather than label encoding
Comment: How one-hot encoding solves the problem? since using one-hot encoding also results 0s and 1s.when i apply k-means it calculates distance.so it may results in decimal .How to solve that. @Chopin
Answer: Label encoding is not a good idea if the nature of categories are not ordinal (it is actually not my favorite anyways). Use one-hot encoding and see how it works. You may apply a feature extraction on top of it, e.g. PCA, to reduce the noise coming from sparsity. The other idea is to label categories by their fraction in the feature, for example:
[a,b,b,c,a,a] --> [3/6, 2/6, 2/6, 1/6, 3/6, 3/6]

Answer: The best way to encode the data will be through any encoding mechanism like label encoder etc. But before handling the categorical variable check the correlation of a categorical variable with the target variable using the feature selection methods like chi square test with selectKbest.
Answer: You can quantify correlation, or more precisely association, between categorical variables using something like cross-entropy. There's an available library dython to compute such association values. Also I am curious why do you want to do clustering ? What is your expected output?
Answer: I think the k-prototype algorithm is what you are looking for.
https://link.springer.com/article/10.1023/A:1009769707641


How to combine data having similar distribution?

Question: I have a collection of time series data with data points of around 2 years of daily data. I am thinking of a way to increase the number of data points in it so that the neural network gets a better understanding of the fluctuations in the data. I am suggesting a hypothesis where I try to cluster similar time-series data following similar distribution, in order to increase the number of data points fed into the neural network. Is this a correct way to approach the problem? If so, on what basis do I combine these similar data together so that I can feed it into the neural network/model?
Answer: Grouping values together is commonly called quantization or binning. Binning increases the signal-to-ratio in data.
Generally, time-series data is binned by time (also called rolling-up). For example, rolling-up all values over a range of days into a single month value.


What kind of mechanisms are there to give an object free rotation?

Question: I am doing a project where there is a plate with a hole on it where one ring will be mounted. The ring and plate need to be attached somehow. However, the ring must be able to rotate around the roll axis. I already have some ideas, but there are too complicated. (with bearing, etc) My questions is: what are some similar mechanisms that I can inspire? (The picture shown below is the basic demonstration of the project. The ring which is needed to be able to rotate is shown with the red color)
Comment: Show a picture of what you want to achieve, then we may be able to help.
Comment: What is so complicated about using an off the shelf bearing or bushing?
Answer: Commercial display stands may give you an inspiration. You can simplify the idea for your project.
For example: https://tr.aliexpress.com/item/32915896443.html
Answer: Make the external surface of the red ring have a bearing track and the matching track on the interior of the black plate so you have a roller bearing created by the two items.
Or have the track on the red ring with 4 or even 8 holes drilled into the plate which have screws with a roller at the tip.
Comment: But in this case, the ring will not rotate I guess. Or am I missing something?
Comment: @mr21 key word roller : "with 4 or even 8 holes drilled into the plate which have screws with a roller at the tip" or even a ball bearing both spring loaded. It was an image to give you the idea, not a working drawing....


Is it appropriate to email a professor about something unrelated to class?

Question: I have a professor currently that I have previously had in a class on a different subject.  Would it be appropriate to email them with a link to an article I found that relates to the previous class' subject (but not to the current one)?  There are no longer office hours due to school moving online, but I'm unsure if an email would be considered a waste of time because it would essentially just be sharing an article that she may have already read.
Answer: I assume you mean something related to academics rather than a completely random meme/cat video.
If so: yes, it's totally appropriate. Discussing cool research topics with students, especially when it's free from the context of grading, is one of the most fun aspects of a professor's work. I absolutely love it when students email me links like that.
And if the professor thinks it's a waste of time, they'll reply with a curt thanks and ignore the link, or simply ignore your email altogether.
Comment: Hmmm, unless you know the prof has some special interest in cat videos. But a shared interest is fine to comment on, not necessarily an academic subject. Maybe you are both Harley riders, for example.
Comment: I would have no issues with my students sending me cat videos
Answer: I see no problem with this. It is possible that the professor will be interested. We can't read everything, after all, so may have missed it. And the fact that it relates to something other than the current class is of no importance.

Hi Prof X. I just came across this article related to last semester's course and thought you might be interested. ...

Short, sweet, informative.
In fact, even if it isn't related to any course, it might be of interest.


How to products disable using attributes name with mysql in magento 1.9?

Question: Magento have 26500 products are available and I want to disable all this product using MySQL because via Magento take lots of time. all products attributes set name is Diamond and Diamond id is 9. Please help me in this case.
Answer: You can do this with a product csv import. Export and filter using the relevant attribute and in the csv change the status to 2 and re-import. It's a lot safer doing it this way than a direct SQL query.
Answer: First of all, DON'T think the writing SQL way. It's because the "Status" attribute id might NOT identical in each version. Modifying records directly can cause unexpected result.
Instead, I'll recommend you to use export CSV way to do your task.

Login to admin panal, go to System=>Import/Export=>Export
Select "Products" on "Entity Type", and click "Continue" on the bottom.
Wait for a moment, the browser will prompt you to download a CSV file.
Open the CSV file using MS Excel or other equivalent spreadsheet software.
Here I use Excel 2016 as example. Go to Sort & Filter and select Filter
Click the filter under _attribute_set and select Diamond
Move to status, change all the values to 2 and save the CSV.
Go back to admin panal, then go to System=>Import/Export=>Import
Select "Products" on "Entity Type" and "Replace Existing Complex Data".
After selecting the modified CSV,  click "Check Data". Your data should be valid. And click "Import" after that.

Tested on Magento EE 22.214.171.124, equivalent to CE 220.127.116.11
Comment: A much better answer than mine :) Choose this one! The only thing I would say is **don't use MS Excel**. Use OpenOffice and save the csv as UTF-8 encoding.
Comment: Thank you PY Yick it's working fine.
Any other solution for Delete products ?
Comment: @DhirendrasinhDRC For delete products, simply keep the products that WANT to delete. And on step 9, select "Delete Entities"


quotation marks「」vs ""

Question: In japanese writing, the ubiquitous 「」is used to mark speech. I have seen "" being used instead of 「」especially on messaging apps. Question is, what's the difference? For the record, I have only seen "" being used in messaging apps
Comment: Duplicate but the Q&A is in Japanese: https://japanese.stackexchange.com/questions/19004/ダブルクォートと鉤括弧かぎ-かっ-この使い分けは
Comment: There is no such a rule as "use only double-quotes in message apps", so you may be seeing some technical problem specific to your app.
Comment: @naruto I didn't mean to say that double quotes can only be used in messaging apps. What I really meant was, I have seen it in messaging apps only so far and not in books, etc
Comment: @DariusJahandarie Sounds to me like there are really no fixed rules and "" really just marks as phrase that one wants to emphasize
Comment: The English quotes may easily get confused with the voice symbol.
Answer: The primary function of quotes is to enclose what someone said or thought, usually along with a quotative-と. For this basic purpose, the "proper" Japanese quotation marks (「」) are normally chosen, but other symbols are sometimes used in informal situations.
To highlight important or unfamiliar words, various symbols including 「」, " ", 【】, 傍点 and so on are used, according to the writer's preference or the rule of a publisher. (Japanese does not have italics.) Perhaps 「」 is the most traditional, but " " is equally common. In general, many Japanese people do not make a strict distinction in the use of these symbols (see this and this) to highlight words, so you don't have to worry too much.

quotation marks「」vs ””


Adding words to an instrumental only piano piece. Can I perform the song as my own?

Question: A search finds no words to the copyrighted song title.
Comment: If the music is copyrighted you can't perform it just because you added words.
Answer: The copyright holder retains copyright to the music, and your adding words doesn't change that. You can perform it privately under limited circumstances (e.g., for friends without payment), but if you perform it publicly or for money then the same copyright restrictions apply to your setting as to the original piece. In fact, the restrictions may be stronger, because the "automatic license" provision may not apply after you've added words. There is a parody exception if your words comment on the song, but it's very limited.
Answer: Melodies are copyrightable. You probably can not legally use the melody without permission.
Chord progressions are not copyrightable. You may use chord progressions freely.
For a piano piece, the distinction between melody and chord progression may not be easy to determine.
As always, check with a copyright attorney. The Copyright Handbook by Nolo Press may help.


Own two colonial nations in the same area

Question: As Ireland I have Holland as a vassal. Both of us have colonized Brazil so there is an Irish Brazil and a Dutch Brazil. Will annexing Holland result in having 2 colonial nations in the same colonial area? Or will the two merge?
Comment: Have you progressed far enough into the game to have found the answer to this? I'd say that normally you would get 2 different colonial nations both under Ireland, but I have not had any personal experience of this.
Comment: I am currently diplo-annexing Holland. I will find out in a few years.
Answer: In case there was no answer yet, this would indeed result in 2 CNs in the same region.
Comment: Yes, it did. The weird thing is when gaining territory. So far, the territory gained from Portuguese Brazil was given to Dutch Brazil. I do not know if this is based on the proximity to Dutch Brazil (compared to Irish Brazil) or it's just random (select first)


Why some airliners have autostart and others don't?

Question: So some of the more modern FADEC equiped planes (specifically airliners like the 787) have autostart and will self monitor the engines during startup. The one thing that confused me was how a 747 could have auto start, and another 747 wouldn't have it. Is the auto start built into FADEC or is there a separate component necessary? Also, why doesn't the 737 NG have Auto start?
Answer: The simple answer is that not all models of the 747 are equipped with FADEC. The aircraft was first introduced in 1968. FADEC-1 was introduced in 1988. It would make sense that all 747's made during those 20 years would not have it.


Night in Minecraft Survival

Question: I am a beginner in Minecraft and am not the best at defending myself at night when all the hostile mobs start spawning. I dig myself a three block deep hole in the ground and place a block above my head. This method wastes a lot of my time and I feel like I should be able to defend myself. Any tips about how to get ready for fighting monsters in the night during day?
Comment: Out of curiosity, but if you're hiding in the hole, why not craft a bed and just skip the night?
Comment: Don't know about beds but happens to know nether fortress? Anyway, check [fandom](https://minecraft.fandom.com/wiki/Bed).
Comment: I'm sorry, I don't understand. How do you get to skip the night? As I mentioned, I am a beginner and don't know much about Minecraft.
Comment: Craft a sword with stone, then find a cave and mine some iron in order to craft an armor.
Answer: Hello Akshaya Gunnam and welcome !
You can sleep once the night begin to skip to morning. To craft generally and a bed in our case you will need a crafting table. Here are the steps:

Chop some trees to get logs. You will need 32 logs. You can convert 4xlogs to Wooden Planks.
Convert all logs to 8 Wooden Planks.
Craft a crafting table (you will need 4 Wooden Planks to craft a crafting table).
Kill some sheep to get at least 3 wool from them
Use your crafting table from step 3 to create a bed using 3xWooden Planks & 3xWool
Comment: OP is asking for how to fight and what to do to get prepared for night, not how to skip.
Comment: That's true but it's the best alternative when you start the game. You can sleep a few nights until you are stronger and able to fight and survive night
Comment: Thank you for the advice about the bed. I have always wondered what they do. Now, I can utilize my time better for mining and crafting!
Comment: Glad i could help :) you will get stronger day by day so you will finally be able to do more during the nights without having to skip to morning

Night in Minecraft Survival


AWS security group inbound rule. allow lambda function

Question: I run a service on my EC2 instance and I want to setup an inbound rule that only allows my lambda function to access it. The security group allows me to restrict access by a specific IP, but I don't think that lambda functions have a specific IP assigned. Is there a way to do what I want?
Comment: what was your solution to do that? Thanks
Answer: If you are enabling VPC access for your Lambda function, as per this blog post, then you will create a security group for your Lambda functions to use within your VPC. All you need to do at that point is go into the security group your EC2 instance is using and grant access to the security group the Lambda function is using. This is the method I recommend.
If you are not using VPC access then your EC2 instance would need to be publicly accessible and you would basically be going over the internet to access the EC2 instance from the Lambda function. If that's the case then there is no good way to restrict that in the security group. You could (with difficulty) open it up to only requests that originate within AWS, but that still leaves it open to all other users of AWS. If you must go over the internet to access your EC2 instance from Lambda then it would be best to send some sort of security token with each request Lambda sends, and ignore any requests on the EC2 server that don't contain that security token.
Comment: @museshad outbound rules should be empty (the default which allows all outbound). The inbound rules should also be empty since inbound rules for Lambda don't make sense, due to the fact that Lambda functions don't sit around listening for incoming network traffic, they only run when invoked by the AWS API. You only need to assign a security group to the Lambda function so you can reference it in the inbound rules of your other VPC security groups.
Comment: Assuming the Lambda is setup with VPC, then what should be configured in the security group created for the Lambda- meaning what inbound/outbound rules should be setup in this security group?
Comment: Apart from this, security group of lambda should have inbound rule for allowing all traffic to the security group of VPC endpoint, and further : security group of VPC endpoint should have inbound rule of allowing port 443 to all IPV4 as well...
Comment: @MihirBhatt You are correct about the security group of the VPC endpoint. You are incorrect about the Lambda security group. A Lambda function never receives a direct inbound network connection, so it does not need inbound rules at all.
Comment: @MihirBhatt no, absolutely. VPC endpoints do not generate inbound traffic, they are only connecting your resources in your VPC with an external service. The only needed rule in a VPCe SG is the egress one (only 443 port). Not generating connections there is no need to allow traffic from VPCe, whatever the resource is using it (Lambda, EC2, etc) because SGs are stateful and responses are automatically allowed.

On the other hand, Lambda is invoked ALWAYS via API, no ingress rule for it needed too.
Answer: What happens if we want our Lambda function to access resources in our VPC? This is a bit of a puzzlement because the Lambda function does not have a stable IP address that we can use as a source in our VPC security groups or in our subnet ACLs.
AWS has overcome these limitations by allowing you to specify a subnet and security group to associate with the Lambda function. You would think that this security group and subnet ACL would control traffic in and out of the Lambda function, but this is wrong. Firstly, Lambda functions do not listen for traffic on any port and so the concept of inbound traffic to a Lambda function is not applicable. Secondly, outbound connections from the Lambda function to VPC resources are not restricted in any way by the Lambda function's security group. So, what is this mysterious Lambda function security group good for and how does it work?
It turns out that the Lambda function's security group is just a naming placeholder that we can use in our other EC2 security groups. For example, a Lambda function can make a GET request to an EC2 instance on a private subnet in your VPC. We start out with two security groups. The first one is a normal security group that controls traffic to and from our EC2 instance that will be serving up the files on port 8080. It has a single inbound rule that allows port 8080 traffic with a source being the Lambda function's security group. Recall that security group rules can specify source or destination as another security group which is a placeholder for all the hosts that are members of that source or destination security group.
The Lambda function's security group has no rules whatsoever. None are required. It is merely a placeholder for the Lambda function that allows us to specify the Lambda function as source in our other EC2 security groups. Remember that the Lambda function has a random IP address that changes from day to day and hour to hour, so it is not possible to specify it as source for the inbound traffic to the EC2 instance.
Security groups normally control traffic in and out of a network interface but in the case of an AWS Lambda function security group, there is no interface and no rules – it is merely a placeholder.
Comment: Thanks. I think you've explained the underlying concept quite well. However, my actual exp has againsted you suggestions re
"Secondly, outbound connections from the Lambda function to VPC resources are not restricted in any way by the Lambda function's security group."
or
"The Lambda function's security group has no rules whatsoever. None are required."
I found that I'll still need to keep the outbound rules in the Lambda security group, otherwise it won't work.
For inbound rules, as you said, I've 0 rule in the Lambda security group.
Comment: The statements related to egress/outbound rules on Lambda function security groups are incorrect. Lambda function SG egress rules operate the same way as they do for EC2 instances.
Answer: A Lambda with no VPC association can reach the Internet through outgoing logical Network path(Managed by AWS Network out of the box).If that Lambda wants to send traffic to any Internet reachable resources on the recieving ends you will see traffic is comming from an arbitrary Public IP address (obviously from Amazon Registered IPs). This will not be a single fixed address. So it is almost impossible to Allowlist incomming IP in your EC2's SG since the next time the IP that traffic is being sent from can change (although from AWS CIDR range but for sure allowlisting that in SG will defeat the original security purpose).
However if you asscoiate the Lambda with a VPC, You can have extra controls over in the VPC Network. This is Because then Lambdas will be assigned with Internal Network Interfaces from your VPC IP range. Let's say you want that EC2 server to only be accessible from the Internal vpc network, therefor you place that EC2 in your Internal Subnet with no Public IP assigned. Now You can set SG on your EC2 to only accept IP from Internal CIDR range of your VPC. Since Lambda is now part of your VPC it will get IP from it's Private Subnet (via ENI) you can add internal range to the the SG configured for your EC2 (just make sure not running out of IPs, If you are going to have lots of Lambdas run in parallel you need to have pretty handful  of IPs defined in your VPC CIDR range).
Now in the given scenario if you want to provide Internet connectivity to resources located in Private Subnet of your VPC you can add a NAT Gateway in Public Subnet(Routable Subnet to IGW) and  make sure Internal resources from your Private Subnet can Route to that. Therefore all your component within the Internal subnet will be assigned with a Routing Tables pointing to NAT and subsequently the the Internet.
Comment: The statement "Lambda with no VPC association will be on the Internet and assigned with an arbitrary Public IP" is misleading. Lambda functions don't have assigned public IPs. They have network interfaces with assigned private IPs and they potentially have a route via NAT to the internet. By default, i.e. if you do not configure a Lambda function to connect to your VPC, then the Lambda service runs your functions in an AWS-managed VPC with access to AWS services and the internet (via AWS-managed NAT).
Answer: Your Lambda will have a temporary IP assigned to it when it runs.
If you configure the IAM role attached to it so it can Allow/Revoke Security Group Ingress, you can make it "let himself in" to your sec group.
Check out this article for an example on adding an IP or CIDR block to your inbound list.
I would clean it up straight away when the function is done.
Answer: You can refer below articles to do the same,
1. https://medium.com/@justanotherspyy/how-to-connect-your-lambda-function-securely-to-your-private-rds-instances-in-your-vpc-29789220a33
2. https://medium.com/orchestrated/steps-to-secure-aws-serverless-lambda-part-1-a6e5d1b05f45
The summary would be,
1. Create a role for Lambda using below two policies,
AWSLambdaBasicExecutionRole — provides CloudWatch logging.
AWSLambdaENIManagementAccess — provides ENI description, creation, and deletion.
2. Put lambda in the same VPC of EC2 and create a security group for the lambda function.
3. Put this security group in EC2's security group's inbound rules.
Answer:
Apart from creating VPC endpoint for secret manager

security group of lambda should have inbound rule for allowing all traffic to the security group of VPC endpoint, and further : security group of VPC endpoint should have inbound rule of allowing port 443 to all IPV4 as well...
Comment: The ingress part is totally wrong.


Proof of law of reflection

Question: When proving the law of reflection using huygens construction I do not understand why a tangent is drawn to the semi-circle (i.e the line CD)
Comment: Possible duplicate of [Huygens' Principle During Reflection: comparing wavelets from before reflection with wavelets from during reflection](https://physics.stackexchange.com/q/161409/)
Answer: The tangent makes sense only as a common tangent to semicircles of different radii centred on different points on AC and representing 'wavelets' emitted from different points on the reflector when  the incident wavefront AB hits them. The common tangent is the 'envelope' of the secondary waves and, according to Huygens's principle is the reflected wavefront.
If I may say so, your diagram isn't very helpful, and it's irritating that the directions of propagation aren't at right angles to the wavefronts!

Proof of law of reflection


Live action version based purely on manga

Question: There are a lot of live actions that are based from anime. To name a few: Paradise Kiss, Kimi ni Todoke and Lovely Complex. Has there ever been a live action film that was purely based on manga, meaning without the manga becoming an anime? Or is it not possible to base a live action film purely on manga (since a manga that has its anime version defines its popularity)?
Comment: Densha Otoko and 20th Century Boys come to mind
Answer: There are plenty of cases of this. Yankee-kun to Megane-chan (for some strange reason it was localized as Flunk Punk Rumble in English) is one such example of a manga which never had an anime. Jin is another example which actually had both Japanese and Korean live action versions, and again no anime version. Neither of those are technically films, but there are plenty of film cases as well, including Nana to Kaoru (no Wikipedia article) and Liar Game - The Final Stage. I know of at least 5 other cases of this (and I'm no drama expert), but I'll spare you the list because it's not terribly relevant.
There's really no reason that this should be an uncommon thing. Both dramas and anime are expensive to produce, but that isn't really a reason to produce an anime first. Very successful manga often have both drama and anime adaptations (for instance, GTO). The only reason why you see fewer dramas based on manga than anime is because the physical constraints for a live-action series are fairly limiting compared to anime. When there aren't any such issues it's pretty common for manga to be adapted only as a drama and not as an anime.
If you head on over to some site which indexes J-dramas and K-dramas, you'll find plenty more examples. One such site is mydramalist.info. Another one is mydramalist.com.
If you're only interested in J-dramas, then Wikipedia has a category for dramas adapted  from manga. Many of those don't have anime adaptations (easily a majority). For films, it seems that more of them also have anime series, but it's still roughly an even split. This list on Wikipedia is the corresponding list for films, though it does include anime films as well so you'll want to only count the "live-action" ones.
Comment: @xjshiya I don't know about that. Just browsing through the top dramas on the second site, it seems like a lot of the manga-based ones don't have anime versions. I'd estimate at least half of them don't. Even in the cases where there is an anime version, often times the drama came out first, and it's almost always based on the manga version, not the anime version.
Comment: I'm only aware of live-actions that are based on anime. Or probably, I don't read manga that much. :) Is it safe for me to assume that there were more live actions films that were based from anime than films that were based only on manga?


How can I type or input Unicode characters using a code point on the iPhone?

Question: I'm aware of the ability to use accented characters by holding down a key until they appear (ie. á ü etc.); however, I'm curious as to how, if possible, one might enter a code point in hexadecimal format or otherwise to output the corresponding character?
Comment: Dori, I see that you closed this as an exact duplicate, when in fact the question is more specific than simply entering symbols, rather my question has to do with the ability to input Unicode characters without the assistance of some other app. For example, the Mac OS allows a user to type ALT + 4-digit-hex if the keyboard is set to "Unicode Hex Input". Would you please reopen it since an answer might address multilingual concerns not limited copy/paste symbols? Thank you!
Comment: @Kyle Cronin: Technical terms here might yield a better answer. So would you mind changing the words "by ID" in the question to "using a code point"? You'll see much written about Unicode being misunderstood in the computing world, and I'd like to be careful not to spread any misinformation or introduce ambiguous terminology in an already complex subject! Thank you :)
Comment: @Kyle Cronin: Just out of curiosity, and hopefully to learn something new, what does "ID number" refer to in the title edit, and how is it related to the terminology "code point"? Thanks for reopening!
Comment: @mkelly33 I wasn't sure what it was called - if you think code point is better I can change it
Comment: A "code point" aka "code position" are just the technical terms used by unicode.org http://unicode.org/glossary/ Basically its the same thing as a unique ID, but specifically integer. The most common encoding I've worked with represents code points in hexidecimal.
Comment: It's a good idea— you might want to send feedback to Apple if it's not already available.
Answer: UniK - Unicode & navigation Keyboard extension seems to be the closest to a character map and it also functions as a keyboard extension. You actually have to type hexadecimal code points in this app.
Comment: This answer should be the accepted answer! This is exactly what the question was looking for. Would give this answer 10 upvotes if I could
Answer: There are applications in the App Store that display all of the characters allowed in the Unicode set that you can copy and paste into other applications like Mail and the like. Searching "unicode" in the App Store brings up a whole slew of them, both free and paid.
There is also Glyphboard (visit with your iOS device) that you can save as a bookmark on your iOS device for an easy interface to some of the more popular ones. This is very lightweight and changes every so often.
Comment: Thanks for the comment Phillip. Where is it documented that "full Unicode set in the keyboard doesn't exist"? How did you arrive at this conclusion? Much appreciated!
Comment: I don't of any publicly available, but in the documentation available to developers there are lists of keyboards available. There are a lot of language-specific keyboards that include characters in the Unicode set, but there is not a keyboard that is simply the Unicode set.
Comment: I swear I saw this at one point, but I didn't link to it and finding it again is appearing to be a difficult task. Sorry.
Comment: Thanks for the suggestion, but I'm hoping there's a different, perhaps more technical way to natively enter via some keyboard combination a hexadecimal or some such format to output characters in the basic multilingual plane, and perhaps in the Unicode code space beyond.
Comment: Natively—meaning direct iOS support—for the full Unicode set in the keyboard doesn't exist. All solutions will be third party, and given there are so many of them, there is bound to be one that does what you want it to do.
Comment: No worries Philip. Hopefully, this question might spurn others to find an answer or encourage the engineers at Apple to implement it. I the meantime, please don't take offense to me not having marked this as an answer. I'm optimistic that we'll soon find this available via some special setting or key combo. In a very internationalized technology world it would seem only appropriate that this feature exists--even if it is insufficiently documented at the moment. Thank you so much for taking the time to look into this.
Answer: I wonder if you ever found a way to enter Unicode characters directly on the ipad?
It's 2017.09 and the closest I've found is the app Unichar. Can't enter (uni)codes directly, but it has 18 unicode pages avaible (in the paid version, 8 in the free version.) Interesting is that it installs as an app that you can open, but also has a keyboard with the same level of features as the app and similar interface
This is as close of an answer as I've found to the same question. It's odd apple resists users' interest for so long.
Comment: I think it would be hard to convince Apple that any significant number of users needs hex code character entry.  Emoji, for example, require entry of 8 characters, which is totally impractical compared to any sort of palette system.
Comment: @TomGewecke Perhaps, but royroye actually found an app that does what the original question intended. Why did it take until 2015 to create an app that does this needed function?
Comment: It's 2021: I found this link to a few different apps for ipados, and some or all also work on ios. I bought UniChar a while ago, and use it as an optional keyboard for some special characters and for ⫸decorative text⫷. It offers limited character panels for free use. It does not offer every single character, but has a good selection and two interfaces (stand-alone app, and keyboard).
https://www.apple.com/us/search/unicode?src=globalnav
Answer: I have been looking for similar and the best third party app I've found for arbitrary unicode input is called UnicodeLab.
It allows you to input any unicode in decimal or hex, view it in multiple fonts, and copy it to the clipboard. You can also cycle through neighboring character codes easily.
It is free.
Comment: A very cool app indeed, but I'm seeking a way to input Unicode character using the ALT + 4-digit-hex if the keyboard is set to "Unicode Hex Input". Thank you for the suggestion!
Answer: I think IOS don't provide unicode Hex Input because it could impact the performance. East-Asia input consumes CPU/memory 100 times more than Latin input from my experiences.
Comment: This answer is total nonsense and should be deleted.


Session Isolation Issue with local SQL Anywhere Database

Question: I am migrating an existing set of applications from Win XP to Win 7.  We have a 3rd party application which is launched by and runs in the user's session which accesses a local SQL Anywhere 9 database via ODBC (launched on demand using dbeng9).  On the same machine we have an ASP.NET website which also accesses the local SQL Anywhere database via ODBC.  These two applications play nicely together in Win XP because both processes are running in Session 0.
In Win 7 the ASP.NET site encounters an ODBC error stating that the specified database file is already in use.  This is because the 3rd party app starts first and spins up an instance of dbeng9 (via ODBC) in the user's session (usually Session 1).  Then, the ASP.NET spins up and attempts to connect to the same database.  The ODBC driver sees that an instance of dbeng9 is not running in the current session (Session 0) and attempts to spin up an instance at which time it is unable to access the database file because it is already in use by the logged on user in Session 1.
Does anyone have any suggestions for solving session isolation issues with local SQL Anywhere databases?
I thought about running dbeng9 as a service rather than allowing ODBC to spin up an instance on demand.  However, because SQL Anywhere is bundled with the 3rd party product the PCs do not have dbsrv and I'm not sure how this would impact the licensing.
The ASP.NET site is only accessed from the local PC.  Would running the ASP.NET site in a 3rd party web server cause it to execute in the user's session?  (Note: because this runs on 1,000 machines a free or very low cost option is a must.)

Is the ASP.NET Development Server
that is bundled with Visual Studio
redistributable in this manner?
Can IIS 7 or IIS 7 Express be configured to run in "local only"
mode in which it executes in the
user's session?
Comment: Apparently running "w3wp.exe /debug" will force the ASP.NET worker process to run in the logged on user's session, but I haven't figured out how to get IIS to launch the worker process this way.
Answer: As long as you are running SQL Anywhere version 22.214.171.12420 or later, a database server running as a service should be visible via shared memory from clients running in any session on that machine.
If you are able to create a service using the dbsvc utility or Sybase Central, that would be your best bet. You'd have to talk to the third party vendor to see if this is allowed under your license.


Does a South African citizen with a UK visa need a transit visa for Amsterdam?

Question: I am taking my son to the U.K he has a South African passport so therefore has a visa for the UK. We are flying via Amsterdam, does he need a separate visa for Amsterdam ?
Answer: As stated in Timatic, the database used by Airlines:

TWOV (Transit Without Visa): Holders of onward tickets transiting by the same or first connecting aircraft.

So if the trip is in a single booking, he does not need a visa


Hadamard/Phase/Hadamard and Inversion about the Mean

Question: I understand the matrix multiplication behind Grover's algorithm, but I'd like to get an intuitive grasp on why sequence of gates Hadamard-Phase-Hadamard does inversion about the mean. Can anyone help?
Answer: I'm not sure whether it's completely intuitive if it still has some formulas in it, but here's a try. (I prefer term "reflection", since it makes the geometrical interpretation a bit simpler, but I think they are used interchangeably.)

First, let's convince ourselves that Controlled Z does inversion about the $|1...1\rangle$ state.
Controlled Z flips the phase of $|1...1\rangle$ basis state and keeps the phases of other states unchanged, so it can be written as $\mathcal{I} - 2|1...1\rangle \langle 1...1|$, which is the reflection about the $|1...1\rangle$ (with an extra global phase of -1, which can be ignored).
Second, let's see how to represent reflection about any state $|\psi\rangle$ in terms of reflection about the $|1...1\rangle$ state, given that we know a unitary $U$ that prepares state $|\psi\rangle$ from the $|1...1\rangle$, i.e., $|\psi\rangle = U|1...1\rangle$.
Reflection about $|\psi\rangle$ is
$$2|\psi\rangle \langle \psi| - \mathcal{I} = 2 U|1...1\rangle \langle 1...1|U^\dagger - \mathcal{I} = U(2|1...1\rangle \langle 1...1| - \mathcal{I})U^\dagger$$
So you can represent that reflection by applying the following sequence of steps:

$U^\dagger$
reflection about the $|1...1\rangle$
$U$

Finally, let's see how to prepare the mean state $\sum_j |j\rangle$, starting with the $|1...1\rangle$ state.
The easiest way is to apply X gate to each qubit to get $|0...0\rangle$, and then to apply H gate to each qubit to get an equal superposition of all basis states.

Putting this all together, we get the following procedure:

apply H to each qubit
apply X to each qubit
apply Controlled Z with most qubits as control and last qubit as target
apply X to each qubit
apply H to each qubit


Any downsides to using an A-mount lens on an E-mount Sony body?

Question: I might be able to get a Sigma 60-600mm DG HSM (not DN) lens for a good price, used, which has an A mount. I have an E mount body (a7r3), and was wondering if, combined with an A to E adapter (probably this one?), it would work reasonably similarly to the DG DN version of the same lens, since they're both full-frame lenses. Or does the adapter cause a loss of aperture or cause autofocus or other issues?
Comment: "... was wondering if... it would work reasonably similarly to the DG DN version of the same lens" Except **it's not a different version of the same lens.** Different number of total elements. Entirely different type of AF system. Different IS.
Comment: Maybe you can contact Sigma because AFAIK they offer replace of the lens mount.
Comment: @MichaelC I see; do you know how big of a difference there is between them? I haven't been able to find a direct comparison review, presumably because it's assumed the newer DG DN will be better
Answer: There can be some downsides to using these LA-EA* adapters with Sony E-mount cameras, compared to native lenses, particularly with previous generation cameras/adapters. Sony publishes a list of restrictions on a lens-by-lens basis, but only for Sony/Minolta lenses. I would not assume that a third-party lens will work any better than a Sony A-mount lens.
The latest adapter – LA-EA5 – should not cause any loss of light transmission. This adapter has no translucent mirror to deflect light to an autofocus sensor like some earlier adapters; rather, autofocus is handled entirely by the host camera's sensor. Some autofocus modes/features may not work fully (e.g. eye-detection) – these are the kinds of restrictions to watch out for. Watch out for limitations in video mode too.
Sony publishes an online Help Guide for each camera model. Unfortunately the guide for the α7RIII does not cover the LA-EA5, but take a look at the guide for the α7RIV where some of the restrictions for this combo are mentioned.
Note of course that some of these restrictions may not be deal-breakers. At the end of the day, it's the image that counts.
Answer: There are reviews of the Sony LA-EA5 adapter at Brian Smith and at Sony Community. There is some mention of vignetting with a specific Sigma lens which can always be an issue with an adapter.
Answer: What matters are downsides that matter to you and how those compare to the upsides that matter to you.
For example adapters add weight and bulk and are a potential point of failure. But a 60-600mm lens already has weight and bulk so you might not care about the weight and bulk an adapter brings.
Or you might. How others would choose doesn't change that. I mean some people choose large format film despite the downsides compared with digital mirrorless because what matters to them even though most people choose differently.
In the end what matters are the pictures. A 60-600mm lens is likely to produce pictures that wouldn't happen otherwise.


I have Nissan Altima 2013 model S, not sure what type of disks will play in the factory fitted disk player

Question: I have Nissan Altima 2013 model S, not sure what type of disks will play in the factory fitted disk player. As it is not having any logos on it mentioning as MP3 or DVD, not sure which type of disks will be played.
Answer: You can find your answer in the owner's guide. Check page 196 of the pdf –
Answer: The drivers handbook for your car will allow you to correctly identify what radio installation you have. It will also outline its features, what discs you can use and how. The screen on the installation is for displaying information of the radios settings, your preferances and service information, and on some sets GPS. If fitted, it will also display the images from your parking/rear view camera. It is not a DVD player in the sense that you can drive along the road watching a movie. Check out the vehicles handbook.


Are clusters in cluster sampling made randomly?

Question: Knowing that in cluster sampling the population is divided into clusters and a simple random sample is taken of them and then all the elements of the chosen clusters are sampled, are the clusters in the beginning made randomly?
Answer: The clusters are usually made out of convenience. Cluster sampling usually has less precision than simple random samples or stratified samples, but SRS can be impractical in some situations.
One example is sampling 5th grade school children in the country. A SRS would require gathering the names of all the 5th grade children. Depending on the problem, after selecting the sample, people would have to cross the country to gather data across many different schools.
If cluster sampling, schools containing 5th grade would initially be collected. Then a smaller set of schools would be selected and traveled to.
Finally, I'm unsure if you are aware, but there is a two-stage sampling method which allows for a simple random sample of each selected school. What you describe in the question is a one-stage sampling method.
Comment: So the clusters are made according to what idea?
Answer: To answer the question, you should understand why a cluster is formed in the first place. Cluster sampling decreases accuracy of a survey and complicates statistics significantly. It's done because it's often the most convenient way to sample a population.
Generally, the cheapest and most efficient sampling method is to choose a subpopulation that is easy to sample. You would over-sample those "easy" subpopulation and under-sample the "harder" subpopulation. For example, it might be easier to sample schools in New York than schools away from the city.
So to answer your question, clusters are defined by the objective of the survey, and is generally not randomly chosen.


Is index.html required?

Question: I understand that a web server looks for a default page file to serve such as (source):

index.html
index.htm
default.html (Windows servers)

However, I am wondering if this is necessary and what happens if there is no such file name?
My first guess is that the server would display a complete listing of the site's project directory.
Is this true?
If yes, then:

Is there any other outcome except a display of the site's full directory?
Is there a possible way to avoid this without naming a default page file name?
Does this result in a loss of SEO ranking?

If no, then:

What are the possible outcomes?
Does this result in a loss of SEO ranking?
Answer:
I am wondering if [it] is necessary [to have these files?]

No, it isn't strictly necessary to have any particular files on a web server, including any "default" index pages (the ones you listed).

[W]hat happens if there is no such file name[?]

The server will generally do one of five things:

dump a directory list of the files that are available (assuming a default index page does not exist or isn't configured).
block access to the requested resource directory (if specified in the server settings - usually via a 403 Forbidden status code).
serve a alternate index page (if specified in the server settings).
return a 404 status code ("Not Found") (unlikely, but possible).
redirect a user to a valid resource (if specified in the server settings)

My first guess is that the server would display a complete listing of the site's project directory.

This is the default on a number of web servers, assuming that a directory/default index page combination is requested, and the default index page does not exist.

Is there any other outcome except a display of the site's full directory?

Yes, see above.

Is there a possible way to avoid this without naming a default page file name?

Yes, configure your server to do one of the things listed above (other than dump a directory listing).

Does [not having a default index page result] in a loss of SEO ranking?

Maybe.

If you are blocking access to the directory via the server (with a 403 Forbidden) or the server returns a 404, search engines can't crawl your content. Google will definitely not direct people to pages with blocked content (403) or items it thinks don't exist (404).
Redirection or serving another file might cause a crawler to index something unrelated to that directory (though this may not be true depending on what you redirect to). This may affect SEO.
Dumping a directory may or may not help SEO depending on what is dumped and how Google might rank that content.

I am not sure if Google or any other search engine has a direct penalty for a lack of default index pages, but I can imagine they might interpret it in a manner that might negatively impact SEO.
Answer: An basic file for your website like the index.html is not needed but is better to have something like that, else it would display an 404 error because the wasn't found.
If you would like to disable that the website display your files in that directory you must create an .htaccess File. And also the Google Bots can't find your website for SEO because the index.html is missing.

Is index.html required?


How to check if an GameObject exists in Unity2D? (Javascript)

Question: Im making an AI that checks if the player exists or not. How do I check if a certain object exists and put it in a boolean variable?
Answer: try using GameObject.FindGameObjectsWithTag or GameObject.FindWithTag
or by name (or namepath) GameObject.Find
<code>bool playerexists = (GameObject.Find("player") != null)
</code>
Comment: But is there a way to not use a tag? That would be better.
Comment: edited: added find (no tag)
Answer: Unity tutorials explicitly says that "Gameobject.Find()" is a bad way to do this.  It is very resource intensive and is not necessary!  Take a Look at Adam Buckner's tutorial on this subject, "communication between scripts and game objects".  You can find the article here:
https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/communicating-between-components-gameobjects?playlist=17117
I know you may not be too concerned about effiency at this point, BUT! as you polish this, you will become more and more concerned about it, and this will be a good habit to learn now, instead of attempting to fix a bad habit later!
Hope this helps!!!
Comment: `GameObject.Find()` is usually fine as long as you're not doing it every frame.  Once on startup is usually low-resource-cost enough to go unnoticed.  That said, there are still better ways to get a reference most of the time.
Comment: Yeah, you "can" do it, but if you watch that tutorial, which is on the UNity3D website itself, he goes into the many many reasons not to do it.  He even states they added it as a "last resort" kind of solution.  I think unfortunately there are a lot of "self taught" individuals out there, and a lot of instructors who aren't teaching "best practice" but just "I found a way to do it" ... and that's unfortunate.
Comment: Which is why I gave you a +1.  There are much better solutions than `Find()` but the complexity of `Find()` is acceptable in a once-off situation that cannot be solved another way.
Comment: A well considered answer is worthy of the reputation the +1 gives.  A few more like it and you'll have all of the meaningless points you could ever want. ;)


Structuring multi-threaded programs

Question: Are there any canonical sources for learning how to structure multi-threaded programs? Even with all the concurrency utility classes that Java provides I'm having a hard time properly structuring multi-threaded programs. Whenever threads are involved my code becomes very brittle, any little change can potentially break the program because the code that jumps back and forth between the threads tends to be very convoluted.
Comment: I'm keen to see the answers here because I couldn't find any (for Delphi or in general). I ended up using diagrams based on  electrical timing diagrams, which worked but were hard for other programmers to understand (samples at http://www.brighthub.com/engineering/electrical/articles/60453.aspx). But my code was still fairly brittle - it was hard for other people to make changes without the unit tests failing. And I had to extend DUnit for MT use - I hope JUnit at least does MT testing well.
Comment: @moz: UML [Sequence Diagram](http://en.wikipedia.org/wiki/Sequence_diagram) can be useful for documentation and discussion purposes. This diagram is easy to make using hand-drawing, simple applications, or even text editor.
Comment: @rwong: sequence diagrams are basically simplified timing diagrams. I found that as the code got more complex sequence diagrams stopped being useful well before timing diagrams.
Answer: If you haven't already, I highly recommend reading "Java Concurrency in Practice". While it doesn't directly solves your problem, it'll certainly provide helpful background on Java Concurrency, and you'll be able to better structure your programs.
http://jcip.net/
Answer: Look at the GNU/Linux shell pipelines for hints as to how to structure a multi-threaded program.
The pipeline concept of a loop which does reading-working-writing is proven, established, well understood and easy to implement in threads instead of processes.
(I used to write software for radars and sonars, where "real time" actually meant real time.)
Follow the pipeline design pattern.  It's how good, robust software is written.
Comment: Is there a blog or other starting point? Or a book?
Answer: There's a monogram called Structured Development of Parallel Programs, by Susanna Pelagatti. Despite being old (1998 - and hence out of print) the way you structure parallel programs hasn't actually changed much, just the tools available for scheduling and manipulated work units have. The methodology described in the book is still pretty useful.
Comment: Hi Link is dead. Is this in Java? Any github or other working link? thanks
Answer: Study ACE framework - it's a great way to learn design patterns and even grab reusable components for concurrent programming and communication. It addresses many areas of concern for multithreaded programming: organizing and communicating between your threads, synchronizing data access, and performing IO. And it take good care of performance issues too.
Answer: I would suggest "Pattern-Oriented Software Architecture Volume 2: Patterns for Concurrent and Networked Objects".
http://www.amazon.com/Pattern-Oriented-Software-Architecture-Concurrent-Networked/dp/0471606952/ref=sr_1_1?s=books&ie=UTF8&qid=1298970690&sr=1-1
Answer: Check out erlang, it does concurrency quite well, but takes a very different approach to it, by being a functional language with a shared nothing model it removes the need for locks (mostly)

Structuring multi-threaded programs


Credit-default swaps

Question: Can someone explain in laymen terms what exactly are credit-default swaps? And how do hedge funds made a killing on them during the market crash in March?
(I am assuming these are debts that parties cannot pay back and have to be auctioned/sold? How does it work?)
Comment: For general background you may want to review [the financial crisis of 2008](https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%932008) and those who made money from it as described in [The Big Short](https://en.wikipedia.org/wiki/The_Big_Short)
Answer: A credit default swap is an insurance policy against the risk that a bond defaults-- that is, that a payment is not made.
Imagine you run a large pension fund.  Among your holdings, you have $100 million in Walmart bonds.  The risk that Walmart isn't going to make a payment on their bonds is extremely small but not zero.  If that very unlikely event happened, though, your pension fund would take a major hit.  To hedge against that, you'd buy a credit default swap-- you'd pay a small fee (likely an upfront fee and a periodic fee) to the seller of the swap.  In return, if Walmart defaulted on their bonds, the seller would make the pension fund whole.
If the market consensus is that there is a 0.1% chance that Walmart defaults, the fair value of a credit default swap on $100 million in bonds would be $100,000 (I'm doing a whole lot of hand-waving here-- in reality you'd have lots of different bonds with different durations and different default risks, even if the bonds default, bondholders might recover some value in bankruptcy so you likely wouldn't use a full $100 million payout, and there will be spreads so you wouldn't buy at the theoretical fair value).  If you're a hedge fund that believes that the real risk is much higher, you can buy a $100 million credit-default swap for $100,000 without owning any underlying bonds.  If the market consensus changes to now believe that there is a 10% chance that Walmart defaults, that swap is now worth $10 million (again, handwavy math) and you've made 10,000% profit if you sell those swaps to the unhedged pension funds that are now in a panic that their bond holdings are going to tank.
I've seen various articles on the Ackman trade @BobBaeker referenced.  They all talk about it being some sort of derivative but I've not seen any that specifically called it a credit default swap.  My guess is that Ackman was trading a different but similar derivative.  Credit default swaps entered the lexicon during the 2008 financial crisis so articles usually name them specifically if that's what was involved.  Other derivatives aren't as commonly known so I'd guess that "credit protection on investment-grade and high-yield bond indexes" refers to something other than a credit default swap.
Comment: FWIW, in the article I linked, it mentioned that in 2007 Kyle Bass and his hedge fund "made a $4 billion profit by buying credit default swaps after the housing market crashed due to the ongoing US recession." Here's another article which states that [Pershing](https://markets.businessinsider.com/news/stocks/billionaire-bill-ackman-denies-coronavirus-warning-profit-2020-3-1029039279#) (Ackman bought swaps.).  They were probably interest rate swaps, not credit default swaps.
Comment: I wonder if you can insure against a swap writer defaulting ??   (For that matter, I mean, how much "margin" do you have to put up if you write a swap against $100m in bonds as in the example?!)
Answer: A credit default swap guarantees against against bond risk. Swaps work like insurance policies. It's insurance protection against an unlikely event. Think of it as a more complex, more leveraged put.
Bill Ackman turned a $27 million bet into $2.6 billion in a genius investment.
Comment: So it's insurance against a Bond crash?  Which would elevate THAT much to be comparable to that of PUTS?   (p.s. yes that is the article that piqued my interest)
Comment: just checked the 10yr yield went from 1.9% to a low of 0.54% in March crash. (was 3% just prior to 2019 also) So How does that translate to the big gain that he made for such a seemingly low percentage drop. I am sure there's hedging involved, but what are the details of that and how so?
Comment: A credit default swap guarantees against against bond _default_ risk. A CDS does not help you if a bond collapses due to, say, an interest rate spike.

Credit-default swaps


Optimization of Integral

Question: $F(x,y)=\int_a^{b} \int_c^{d} G(x,y,s,t)dsdt$. I wish to find $x$ and $y$ (subject to some constraints) that minimize $F$. $F$ is not expressible in closed form. Is the only way to solve this problem as follows: "Replace different $x$ and $y$ values according to the constraints and evaluate the integral numerically each time"?
Comment: What form are the constraints? Are they linear, quadratic form, non-linear? And similarly, what form is $G$?
Comment: Additionally, is $G$ expressible in closed form? Is $G$ convex? Are $x$ and $y$ independent of $s$ and $t$?
Comment: @John Yes, G is expressible in closed form - I need to check if it is convex. Yes, x and y are indpt of s and t. Also, I tried to simplify the situation. The $x$ and $y$ are actually $k$-dimensional vectors with $-1\leq x_{1}<x_{2}<\dots <x_{k}\leq 1$  and $0 < y_{i} < 1$ with $\Sigma y_{i} = 1$
Answer: Since $G$ is in closed form (as per your comment above), you can express derivatives of $F$ as
$$
\frac{\partial F}{\partial x_i} = \int_a^b \int_c^d \frac{\partial}{\partial x_i}G(x,y,s,t)\ ds\ dt
$$
The same goes for $\frac{\partial F}{\partial y_i}$, so you can perform gradient descent if your $F$ is convex. (I don't recall what the conditions are for an integral of a function to be convex. It may be enough to know whether $G$ is convex just in $x$ and $y$.)
If $F$ is concave, then your solution will be at one of the vertices of your bounding region, since your bounding region is a convex polytope.
Comment: Thanks John. Will give this a try,

Optimization of Integral


How can I use Bootstrap 4 while using Flask for Python 3?

Question: I have checked and found that Flask-Bootstrap natively uses Bootstrap 3.3.7 when you install it by default. But actually I wanted to use Bootstrap 4+ for my project by using Flask-Bootstrap package, any help would be much appreciated of how to update it or anything like that.
 Thanks
Answer: There is a fork called Bootstrap-Flask that is up to date.
That said, however, it is not a good idea to use either Flask-Bootstrap or Bootstrap-Flask. These are very thin packages with a small layer of indirection that primarily serve to obscure your understanding.
Instead, I recommend using the starter template provided by Bootstrap 4, which will always be up to date to whatever version you require using their CDN.
If you stick with Bootstrap, you will soon want to build your own Bootstrap anyways so you can do things like add custom themes. Hacking Bootstrap with CSS instead of using their SASS customization scheme is painful (I did it for a while). The build process is well documented and simple enough, just a few installations required.
Comment: I too want to use the latest bootstrap for flask 1.1. Why hasn't the package been updated anyway ?
Comment: @Jarmos Until it's out of date again. Have you ever actually looked at the code for Boostrap-Flask or Flask-Boostrap? These 'projects' are pointless. Just use the template that is maintained by the Boostrap team that will always be up to date.
Comment: Just a heads up! [Boostrap-Flask](https://github.com/greyli/bootstrap-flask) is being actively developed as of now. It now supports Bootstrap 4 & Flask 1.x.
Comment: I get your point, but actually I wanted something that allows me to integrate onto my  project fast, so I had used Flask-Bootstrap. For example it had different orientation for things like WTForms for Flask.
Comment: @faruk13 So then use Bootstrap-Flask which is up to date. It is exactly what you asked for.
Comment: @okovko true! Besides, lesser dependencies, the lesser risk of sliding into dependency hell.
Comment: I agree but what I am looking for is how to use bootstrap I built in a flask project. Just stick it under static and reference it as a local script I guess???


Any reason to not do a 301 on favicon.ico, apple-touch-icon, and robots.txt?

Question: I would like to redirect requests for these resources to my CDN. Is there any reason to not do this?
Answer: The only reason that I can think of is that services that use them might not follow the redirect - it might not be transparent for them, they may have to actively do it, depending on their implementation.
The only way to know would be to try it out and test your intended use cases - do browsers still fetch them, what happens when you add the test site as a shortcut on a mobile device, etc...


How to get RDP client to process the #@ key on Mac?

Question: I'm using Microsoft's RDP client for logging in on my VBox Ubuntu that is running with VBoxHeadless. This works fine except that the #@ key does not seem to be recognized. Even the xev utility doesn't detect the keystroke.
Does anyone know how to fix this problem? I'd greatly appreciate your help!
FYI: I have a MacBook Pro (model 5,5) with a Belgian AZERTY keyboard.
Note: The #@ key is the one below the escape button in this picture:
Comment: The #@ key?  Not familiar with that.  Using Canadian Multistandard English QWERTY...
Comment: @menns: see my edit :)
Answer: Try pressing ALT + 3 to get the # sign
Answer: Press Ctrl+Alt+2 to get the <code>@</code> sign.


Why don't get the expected result using a SVM training model?

Question: I want to learn a model for recognizing facial emotions. . I used a dataset with 213 samples. I extract firstly features using the Gabor filter. Then, I reduce the data dimensionality with the PCA and the genetic algorithm. Finally, I test performance using cross validation with a test size of 25%, and I got 98% acuraccy. The problem is when I test the SVM model on other images, I don't get the expected result.
Answer: Without seeing the data and your code it's hard to examine and tell what's the problem. Below are what I would think as a first step.
98% accuracy is a high level, so I would initially check for over-fitting.
The ideal solution to over-fitting is using more data. If you can't, then increasing the portion of the training dataset (maybe to 50%) and then going through cv & testing might help.
Another common reason is over/under-represented class. What's the ratio between the classes?


Is reheating coffee in the microwave a bad idea?

Question: Sometimes I get distracted, and realise I've got a cold cup of coffee on my desk. Will reheating it in the microwave do bad things to it? I've heard people say it will alter the flavour, and some people even say that the effect of the microwave on the coffee will produce medically harmful chemicals. Is this true? Should I just chuck it and make a fresh brew?
Comment: I usually just drink it cold, even if it is very old. Maybe you are interested in my somewhat related question : http://coffee.stackexchange.com/questions/295/coffee-in-a-flask-how-long-can-i-store
Comment: I'm sure there is a point if you left it going long enough to carcinogens could build up. I'd be interested if there is a researcher here to find where that point is.

I probably microwave a cup every day because of a distraction at work.
Comment: I think "is it dangerous?" and "will it change the flavour?" are significantly different questions and should, IMO, be posed as two separate questions.
Comment: Couldn't that be already answered in Cooking SE: http://cooking.stackexchange.com/questions/19252/why-does-coffee-taste-awful-after-reheating-it-in-a-microwave-oven
Comment: http://skeptics.stackexchange.com/q/5816/23404
Comment: @fredley what original tags? The first revision has the untagged tag, and don't see any migration stub. So now I'm curious, what happened here? :)
Answer: Although coffee generally becomes staler with time, heating coffee up in the microwave does not produce any harmful chemicals - as long as the container you are microwaving it in is microwave-safe.
The microwaves emitted inside the microwave are a relatively safe form of radiation that cause the water molecules in the coffee to move faster, thus creating heat. This is relatively harmless.
As far as taste goes, you may consider just making a new coffee, as this will always taste better, in my opinion!
Answer: I grind my own beans every morning and use a drip coffee maker to make a big pot. I've found that the best way to keep a pot of coffee tasting good is to turn off the hot plate under the coffee immediately after brewing. Let the pot steep for a few minutes for better taste.
Despite all the opinion otherwise, I don't think microwave reheating ruins the coffee at all. Of course, the taste does not improve with age, but less heat overall, and reheating is so much better than leaving the coffee on a heat source.
JMHO.


Why were the SI base quantities chosen as such?

Question: The reasons for choosing length, mass, time, temperature, and amount as base quantities look (at least to me) obvious. What I'm puzzling about is why current (as opposed to resistance, electromotive force, etc.) and luminous intensity (as opposed to illuminance, emittance, etc.) were chosen to be base quantities. Does it have something to do with them being the easiest to measure?
Comment: The one that always bugs me is mass: it's _still_ defined in terms of the International Prototype Kilogram: a chunk of metal in Paris. One, that's crazy! Two, I find it unsatisfactory that the SI _unit_ has an SI prefix. Surely, the SI unit of mass should be the gramme...
Comment: @Seamus: I agree, and I like one of the proposals for redefining the kilogram, but the way it looks, it's a bit impractical with our current technology to make a perfect sphere of silicon.
Comment: For whatever it's worth, here goes... [http://www.independent.co.uk/news/science/scientists-fear-kilograms-dont-weigh-as-much-as-they-used-to-2192481.html](http://www.independent.co.uk/news/science/scientists-fear-kilograms-dont-weigh-as-much-as-they-used-to-2192481.html)
Comment: I'm late to the party here, but this [video](http://www.youtube.com/watch?v=ZMByI4s-D-Y) shows we're actually getting reasonably close to an independent, reproducible standard for weight, based on the aforementioned silicon sphere.
Answer: Historical issues I suppose; indeed current definition of ampere is rather stupid (force between two cables in vacuum) in light of the fact it could be done with number of elementary charges per second.
Candela is even worse, because it involves properties of average human eye (so called "luminosity function") -- so in principle it changes instantaneously as people get birth, die and their eyes age (not to mention various eye/brain fractures and treatments).
Comment: I've never understood the Candela at all - why is it a base unit? Surely this psychology and physiology: grounded on a large sample and in some sense meaningful to humans, yes, but hardly a physical base unit!
Answer: Of course, history has its own way of determining things, but I suspect that the greatest reason for the choices of the base SI units was that they were easily measurable at the time. Other quantities such as resistance, magnetic, density, power, are (or certainly were at the time) much more difficult to measure precisely. In this sense, the choices were fairly reasonable.
Answer: SI units are pragmatic so their definition must be easily realized. That is why ampere is the basic unit, since it is easier to measure. Theoretically, the elementary charge is much more fundamental than an arbitrarily chosen amount of current, but that cannot be reproduced with equal or higher precision, at least not now.
I think the candela is chosen more arbitrarily, since its definition doesn't give a specific instruction to measure it. One can also choose lux as the fundamental unit and define it as "The lux is the illuminance of monochromatic radiation of frequency $540\times 10^{12}\,\text{Hz}$  and that has a radiant intensity in that direction of 1683 watt per steradian." I guess this has more to do with historic reasons.
And by the way, if you don't need to take into account the human vision, you don't need candela; watt is better.
Comment: I'm not sure if that is the definition for Lux. Either case, the ratio is 1/683, not 1683.
Answer: We see that candela is very well-defined, without using properties of, for example, a human eye. Let me remind the definition.
The candela is the luminous intensity, in a given direction, of a source that emits monochromatic radiation of frequency $540 \cdot 10^{12}$ hertz and that has a radiant intensity in that direction of $\frac{1}{683}$ watt per steradian.
Ampere of course cannot be defined as a number of elementary charges per second, because without definition of ampere we cannot define a value of an elementary charge! The definitions is below.
The ampere is that constant current which, if maintained in two straight parallel conductors of infinite length, of negligible circular cross-section, and placed 1 metre apart in vacuum, would produce between these conductors a force equal to $2 \cdot 10^{−7}$ newton per metre of length.
What is important, both definitions don't use any prototypes and define clear ways how to reproduce these units inside a lab. Such experiments should always give the same results anywhere in the world - and they do. The definitions are simple and unambiguous. In SI, only the definition of a kilogram uses a prototype, because the definition of mass still causes problems to physicists.
Comment: About the elementary charge: Why would we need to define it? It exists. "One Ampere is the current caused by a flux of  of electrons per second"?
Comment: Due to ampere: We define base unit coulomb by electron charge and so we have ampere as a derived one.
Comment: @piotr - that was the important goal of SI. Before that when units were based on standards owned by another country any diplomatic incident caused havoc - which is why the US inch was different to the British. The french were trying to get away from traditionla units based on king's bodies but also make science and industry work better.
Comment: You didn't answer the question. You're saying that those SI units are well-defined, and I agree. What I'm asking is why of all possible quantities, those two (current and luminous intensity) were chosen.
Comment: My answer is that these two were chosen because they can be easily and unambiguously defined, with the definitions constructed so that these quantities may be reproduced in a lab and always give the same results.
Comment: Due to candela: What about other weavelengths?