Add related record on record creation

Question: My question is at a high risk of being a duplicated one, but that is not for lack of investigation. I've been around with this issue for long, and found nothing to solve it, but it seems such an obvious and common problem, that somebody must have answered this already.
The thing is, i have two related tables, say product and product_images, where product_images refers to product with the field product_id.
In the CRUD (a web app written in php with codeigniter and MySQL as db) i have a form with the product data, and a button for adding images from a pop up.
Question is: is there an elegant/efficient way to add an image to a product when I am CREATING the product (and there is still no product_id)?  Or do i have to save the product first and then add the images on the product edit?
Thanks a lot for any idea! I feel very dumb with this problem.
Comment: Is your question more about the mechanics of inserting related rows i.e. in a single transaction, or, more about the user interface and workflow of entering products, images, and relating them and so how to present that to the user?
Comment: Hi Erik
I guess i can't separate those two aspects. If there is a clear and robust mechanism, maybe involving transactions, that would allow a cleaner an simpler workflow and interface, right? And viceversa, if there isn't, one should find the best workflow in the UI to overcome that lack of such mechanism. But i really don't know.
What could that mechanism be?
Answer: I'd suggest you start with the domain experience that your users will have.
From a technical, data modeling point of view, you might have Products, Images, and Associations between them.  But do you want your users to be able to — or to have to — manage these 3 things separately or do you want a simplified user experience where the user adds Products with Images, and perhaps from time to time adds more images to products.  Anyway, that's a domain decision, not a technical one.

And, sorry, I don't know codeigniter, though, broadly speaking, you have to insert a row into a table before you can get/use its id in an association of some sort.
However, various databases will allow you to see the id after insert yet still within the transaction, so you can insert other rows (in another table that requires the former id as foreign key) in the same commit (i.e. in one round trip to the db), which is about as efficient as you'll get.
For example: MySQL; SQL Server; Oracle.
There is apparently also some support in PHP for getting the last id <code>$conn->insert_id</code>, see more here.
Search phrases "id of last insert"; "identity of last inserted row".
Comment: Thanks Erik. About the first part of your answer, it is precisely the idea behind my original question. I want the user to add the product with some images and, as you said, they can later edit to add/delete some more images. I know how to get the last inserted ID from the db, codeigniter has db->insert_id() for that. But what i don't know has to do with this workflow-> you click a "new product" button -> the form appears -> you enter the product name, etc -> in that form, you click on "new image" -> the pop up shows -> you upload the img -> There! What do you do with the image at that point?

Add related record on record creation


The use of the word 'united' for singular nouns - 'United Kingdom'

Question: I have a question about the word 'united' and its use with singular nouns. For example, the word united is used in the name 'United Kingdom'. How can a single thing (kingdom) be 'united'? I can understand the use of the word for the United States - the States are considered to have joined/ been joined together', but how can one kingdom be deemed to be united? The same applies to names of football teams, for example, Manchester United. Is the word united meant to refer to the people making up the kingdom/football team?
Comment: Have you looked up what the word "united" means in the dictionary? I just did. The first entry answers your question. https://www.ahdictionary.com/word/search.html?q=united
Comment: Two people become **united** in marriage and that singular marriage is called a **union** because it joins two people.
Answer: In the context of use with singular nouns, the word "united" most closely means "complete" or "whole," and often refers to the coming-together of separate parts.
For example, the United Kingdom is actually made up of four countries; England, Scotland, Ireland, and Wales, so is the unity of separate parts (like the United States). In this example, the four countries (or kingdoms, as they used to be) have been united into one singular kingdom: The United Kingdom.
Hope that's clear, but, if not, feel free to ask for clarification. :)
Editing to add on the useful link left in a comment to your post:
https://www.ahdictionary.com/word/search.html?q=united
Comment: Thank you both for the clarification. I had only checked the Oxford Dictionary and its entries were not as clear.
Comment: @Elizabeth. The states of the modern United States are actually fairly similar in structure to the kingdoms of the United Kingdom (as far as I know). One could argue about minute differences, but I'd say that the states of the United States are as unified under the central government as the United Kingdom's "kingdoms" are. The use of "states" over "state" is more semantics than anything. Each US state also has a strong sense of individuality, so that plurality in the country name is reflecting that individuality.
Comment: Thank you for your answer, do I understand it correctly? despite England, Scotland, N Ireland, and Wales have their own local governments, they form one kingdom because they are all under the rule of a Queen. Hence the singular word "Kingdom" is used in the country name. But in the USA, states are largely governed by themselves. Although there is a central government, all the states together didn't form any institution that is larger than the individual states, hence the use of plural "states" in the country name.


How do I tell my parents I don't want to take sides in their disputes?

Question: I'm a young adult, and both of my parents come to me when they want to complain about the other. (They are married, but their relationship hasn't been on good terms for a couple of years.) I don't want to take sides or talk badly about either one behind their backs. How can I explain this without hurting my relationship with them?
Comment: What does "young adult" mean to you? Are you still under 18 or are you in your upper teens/early twenties?
Comment: I'm 21 - I'm not living with my parents but financially dependent upon them while I'm in college
Answer: The best way is to be straightforward, and assertive.

You know I love both of you and it hurts me to see you fighting.  I will listen to both of you and not take sides and it is not fair for you to ask me to do so.  You are my parents, please don't put me in this position.

This starts out in a positive way, then plainly states the effect it has on you, then sets boundaries.  You are telling them that you love them but this behavior is out of bounds.  You are also reminding them of your roles in the parent/child relationship.
Answer: Once grown up to full adulthood and maturity, a problem between two people should be
solved by the two directly-involved people by talking to each other
Addressing a third party in day-to-day arguments sounds as childish as the case when two little brothers fight and one of them screams "Mooooom!!! Bob is being mean to me, tell him to stop!".
This is also worsened by them addressing a person who should be and is too close to both parents.
First, they need to prove their adulthood/maturity by learning to sit down and talk directly to each other and staring into each other eyes.
If that fails, address someone definitely more external than a son/daughter.
That explained, in my opinion your answers could be:

Just be straightforward and declare your point of view.

Look mother/father, I love both of you equally, I can't get involved with this - I'm too close to both of you and this fighting upsets me.

I'd suggest that they take this dispute to someone who is truly impartial and can mediate properly.

Mom/dad, please, stop being childish, this is not the way to deal with problems at your age: every time you argue you act as two little brothers [etc. see above]

a combination of them both
Comment: You're allowed to actually say what other answers say... what happens if the other answer is removed for some reason? Feel free to restate solutions in the body of your answer. You can either quote them directly with attribution or write a similar version of your own.
Comment: I've removed my answer because it apparently wasn't fully formed enough (I'm far too straightforward). Please feel free to include my points into your answer.
Comment: I've replaced your link with Snow's answer. Feel free to edit it or remove or whatever :)
Answer: What's going on is called "triangulation".  In a dispute, sometimes one or both of the parties will attempt to draw a third party into the dispute to make them feel like their position is stronger.  Often they will use your relationship, guilt, or anything available to them to get you into the middle of their issue.
The key here is to recognize when this is going on, which it sounds like you have done.  One thing I've seen done, especially in the workplace, is to say, "I'd rather not talk about someone when they can't defend themselves."  That quite often draws that conversation to a close.
With a married couple, that's harder because feelings run stronger.  To keep out of the middle of this will require a lot of determination on your part and willingness to not accept guilt that will be thrown at you.
First of all, when they start talking about the other, stand your ground.  "Mom/Dad, I'm both of your child.  I realize things are hard between you two, but I love you BOTH and can't get in the middle of this."  "Mom/Dad, I understand you're having a rough patch.  I'm here for you but let's talk about how this affects you and not talk about the other person."  "Look, this is tough on all of us.  By trying to get me to choose sides, you're just making this tougher on me.  I love you both and can't take sides in your issue."  And be firm.
When you hear the "if you really cared" or "don't you think that", the response needs to be firm as well.  "if you cared about me, you wouldn't say 'if you cared'".  "Don't I think that...?  What I think isn't relevant.  It's not happening to me; it's happening to you". You can love your parents yet still avoid being drawn in.  And if you can't avoid being drawn in, a month or two of stepping away may be necessary to keep your sanity. Remember this: you're their child, not their therapist.
If you have access to a minister or trained marriage and family therapist, a visit or two would be good for you.  They can help you learn more about triangulation and how to stay out of it, as well as give you more tools to deal with this.  If your parents' relationship is bad and not getting better, a therapist can help you deal with the next stage of their relationship, whatever that may be.
Answer: I'll be very straightforward. Having my parents divorced from age 4, I have been in that situation more times than I can count. It took its toll on me, but I'm ok now.
What I mean when I say it took its toll, is that I learned to answer them truthfully without feeling like I was being disrespectful, because in fact what they were doing was disrespectful towards me.
Firstly you need to remember that family isn't always a good thing, and the worst part is that you don't get to pick yours, so you might be stuck in a pretty bad situation when you are born. Therefore, analyse your parents as you would analyse any other person, and think whether the situation you're stuck in would be acceptable if your parents weren't actually your parents.
In my case, it wasn't, so all I said was:

Listen here. I DON'T care about your interpersonal problems. That's for you to solve. You are hurting ME and I don't deserve this. Learn to behave yourselves and treat eachother like adults should.

They then realized they were failing as parents, since they were hurting me, their child, and stopped doing that.
Previous attempts to tell them to stop doing it softly like others have suggested resulted in me getting tricked into a trap where they would either tell me I didn't love them or that I should go live only with my other parent or anything like that. Parents at any age have the upper hand in the power relationship with their children, therefore they can use that power in their favour, you'll never win if you let them have a chance to put themselves first instead of you.
Always keep in mind that, ultimately, you are the person that is the most important in your life, so you should be egoistic sometimes if that means saving yourself from harm.
Answer: I would recommend not only to stop taking sides, but stop listening to them complaining about the other person.

Listen, I am your child, you are my mum, I don't want to know about your issues with dad, nor can I help you to resolve this.
  Being told such things is putting me into the position of a referee, a psychologist or a judge, but I am none of this but your child.
  What do you think about what I just said?
Comment: I like the idea of "stop listening to them complaining".


Can SQL Server 2000 and SQL Server 2012 CoExist?

Question: We have OLTP Databases on SQL Server 2000 on my client's Prod Server. Planning to create Data Warehouse on the same Server but use SQL Server 2012. Can I install without any issues?
Comment: Thank you everyone for valuable input. This really helps. Got the point loud and clear. Will definitely thoroughly test with Separate instances and then move to production. You might see me posting more questions if I run into issues.
Comment: Wooooee.. So much negativity.... Why all the down-voting? I feel we have answered the question. Chill out a bit.
Comment: @StanleyJones I don't see any negativity. The question has 2 upvotes. If you are referring to the answers, people probably think that those answers are either wrong or do not really answer the question.
Answer: As stated on MSDN side-by-side installation of SQL 2012 with earlier version is supported. However take note of the instance name, if your SQL 2000 instance is a default instance then your SQL 2012 install will have to be a named instance.
I would take note also that some issues may occur with SQL 2000 tools as your SQL Server 2012 installation may attempt to upgrade any shared components it finds. Although I don't know what of SQL 2000 would still exist in SQL 2012.
Now, my opinion and not the opinion of StackExchange, or my dog...I would not suggest configuring a side-by-side install with a SQL 2000 instance. Not knowing the setup, I would highly doubt the server configuration of a SQL 2000 instance is very well suited to what Microsoft suggest for a SQL Server 2012 installation. Especially considering the fact that SQL Server 2012 is only supported on Window Server 2008 SP2 and higher. This all depends on how old the server is and such but just my opinion.
Answer: You should be able to run separate instances of those versions on the same server without issue, though I usually recommend against doing that in production environments as I have experienced problems in our dev environments with updates sometimes refusing to apply (I forget which, but for us one of the SQL2005 service packs refused to install on the machines that had both SQL2005 and SQL2008 instances present).
SQL2000 does not reach EOL until later this year but it is in the "extended" support period, see http://support.microsoft.com/lifecycle/?LN=en-us&x=14&y=10&p1=2852, so it is likely that MS have tested the combination as part of their release testing process but if you do have problems that are not security related you'll end up paying for resolution if you need to refer to MS support. I would therefore recommend fairly rigorous testing of your own before you try this combination in a production environment. Also see Shawn Melton's points regarding SQL2012's system requirements, which may mean that your old SQL2000 box is not suitable even though it is theoretically possible.
Answer: I tried to install SQL Server 2012 and 2014 on the WIN2008R2 server with Sql Server 2000 Desktop Edition named instance installed. The installation process failed showing error:
TITLE: SQL Server Setup failure.
SQL Server Setup has encountered the following error:
'.', hexadecimal value 0x00, is an invalid character. Line 1, position 444345.
Error code 0x84B10001.
After taking a brief look to the log files I concluded that there may be some unexpected values in the registry with SQL2000 that cannot be processed by SQL2012/14 installation process.
Comment: It was my case too. Same issue
Comment: For information: after removing MSDE (SQL server 2000), I can install MSSQL 2012
Answer: Sure you can.
Just note that you have to install an older version first, and then install the newer one
Answer: I have not tried your exact case, but you will certainly experience some problems (deprecated functions, sql instructions...). You will also have to name your instances carefully.
I would much prefer having multiple instances with the same version. If you wish to migrate your 2000 database, keep in mind that according to the MSDN, the migration from Sql Server 2000 to Sql Server 2012 is not supported, as you need an intermediate step, usually Sql Server 2008R2.
[25/03/2013 Edit] my initial message looked a bit off-topic.
Comment: The OP didn't ask about migration, but about side-by-side co-existance ...
Answer: Yes, you can install SQL 2000 and SQL 2012 as separate instances on the same machine without issues.
Comment: Can you expand and clarify this answer? Why will there be no issues? Have you tested it? Is there a MS paper or web page that reassures of this? (And I don't object to the answer but longer answer are usually more accepted here).


Command like SQL LIMIT in HBase

Question: Does HBase have any command that works like SQL LIMIT query?
I can do it by setStart and setEnd, but I do not want to iterate all rows.
Comment: do you want to limit the results based on some condition or just a simple limit that shown top 'n' records?
Answer: From the HBase shell you can use LIMIT:
hbase> scan 'test-table', {'LIMIT' => 5}

From the Java API you can use Scan.setMaxResultSize(N) or scan.setMaxResultsPerColumnFamily(N).

HBase API docs - Scan.setMaxResultSize
HBase API docs - Scan.setMaxResultsPerColumnFamily
Comment: In order for this to work, there needs to be a comma delimiter between the  and {'LIMIT'...} so, scan 'test-table'**,** {'LIMIT' => 5}
Comment: setMaxResultSize is not available for all versions of Scan, for older versions you need to use PageFilter per @mirsik example
Comment: According to the docs, you specify `setMaxResultSize()` in bytes. If you want a certain number of rows, you need to use `setLimit()`.
Answer: There is a filter called PageFilter. Its meant for this purpose.
Scan scan = new Scan(Bytes.toBytes("smith-"));
scan.addColumn(Bytes.toBytes("personal"), Bytes.toBytes("givenName"));
scan.addColumn(Bytes.toBytes("contactinfo"), Bytes.toBytes("email"));
scan.setFilter(new PageFilter(25));
ResultScanner scanner = table.getScanner(scan);
for (Result result : scanner) {
    // ...
}

http://java.dzone.com/articles/handling-big-data-hbase-part-4
Answer: If one uses HBase Shell, the following command could be used to limit the query results:The "LIMIT" must be enclosed in single quotes.
scan 'table-name', {'LIMIT' => 10}

Answer: A guaranteed way is to do the limiting on the client side, inside the iterator loop. This is the approach taken in the HBase Ruby Shell.
From table.rb ($HBASE_HOME/hbase-shell/src/main/ruby/hbase/table.rb):
Line 467:
  # Start the scanner
  scanner = @table.getScanner(_hash_to_scan(args))
  iter = scanner.iterator

  # Iterate results
  while iter.hasNext
    if limit > 0 && count >= limit
      break
    end

    row = iter.next
    ...
 end

It can be made a bit more efficient by adding scan.setFilter(new PageFilter(limit)) and scan.setCaching(limit), and then table.getScanner(scan). The page filter will ensure that each region server will return at most limit rows, the scan caching limit will ensure that each region server will read ahead and cache at most 'limit' rows, and then the client loop limit checking can break the loop after getting the first 'limit' rows in the order received by the client.
Answer: In HBase 1.2,
the Scan.setMaxResultSize(N) may not act as a parameter of row number limitation. The maxResultSize limit the maximum result size in bytes (cached in the client side). I found the ResultScanner.next(int nbRows) can limit the row numbers during the iteration.

Command like SQL LIMIT in HBase


How to use a polygon as a reverse cookie cutter on features in a Postgresql database

Question: I want to be able to use a polygon in a database to remove all features and parts of features that falls within the polygon. Not as part of a query transferring the database to another database. I want to remove the features and parts of features inside of the database I am working in. Could someone point me to a example of how to do this with a postgis query?
I want to be able to erase the parts of features that overlap the polygon.
Comment: Please edit the question to clarify whether you want "Erase" functionality (remove only those parts  of features which overlap) or just a simple "Delete" of all features which overlap.
Answer: Assuming you have two tables "a" and "b".
Table "a" is the table to be cut.
CREATE TABLE a
(
  id serial PRIMARY KEY,
  geom geometry(MultiPolygon,31370)
);

Table "a" is of type multipolygon because we don't know yet if some polygons will be separated in multiple parts afther the "cookie cut".
CREATE TABLE b
(
  id serial PRIMARY KEY,
  geom geometry(Polygon)
);

Table "b" holds your cutting polygons.
Here are both layers shown in QGIS (a: blue, b: transparent orange):

If you only want to select and see the result you can write this query in the DBManager:
SELECT
    row_number() over() id,
    a.id a_id,
    -- use ST_Multi to force multipolygons:
    ST_Multi(ST_Difference(a.geom, cutter.geom)) geom
FROM
    a,
    -- Create one big cutter to avoid duplicate results:
    (SELECT ST_Collect(b.geom) geom FROM b) cutter
WHERE
    NOT ST_Contains(cutter.geom, a.geom);

Result:

If you want to really update your table to remove contained parts and to cut overlapping parts, you can write:
-- remove parts contained in the "cutter"
DELETE FROM a
USING b
WHERE ST_Contains(b.geom, a.geom);

-- cut the other parts
UPDATE a
SET geom = ST_Multi(ST_Difference(a.geom, cutter.geom))
FROM (SELECT ST_Collect(b.geom) geom FROM b) cutter;

Here is the rest of table "a":
Comment: ST_Multi is to force a multipart geometry. We need to use it because we don't know in advance if some polygons will be cut in multiple parts after the "cutter" has been applied, and it's better to avoid mixed geometry type, so we convert everything to multipolygons;
Comment: Thanks for answering my question with the detail I needed to understand.
Comment: DELETE FROM  table_cutting_happens_in
Comment: Never mind my previous comment. It's past the 5 minutes limit to fix it.
Comment: I tried to do your code sample and I could not get it to work. So I need to understand how it works better. What is the STMulti for?
Comment: I've improved the answer with images and bug fix.


Magento equivalent to MovableType's FieldDay

Question: Does anyone know an equivalent to the MovableType plugin FieldDay(https://github.com/movabletype/mt-plugin-field-day/wiki/Basics) for Magento. I need to be able to create multiple instances of product field sets. (i.e. multiple instruction blocks)
Comment: I dont see any difference between this and the Attributes set in Magento. You might not be aware of the use, but i think what you ask is doable with an attribute set.
Comment: So having multiple instances of an attribute set for a product set is possible?
Comment: You can have one attribute set per product if that is what you are asking.
Answer: You need to create a custom attribute, with a custom renderer.
You will find here an example about how to create an attribute that supports a custom renderer with 2 fields. You can extend that to support a dynamic number of fields.
You can also take a look at how the tire prices functionality is built. I think it's similar to what you need.
Answer:
Magento allows to have multiple custom product fields (attributes) per product.
See admin > catalog > manage attributes > attributes
As in one store you can sell different type of products, with different fields, magento allows for each product define it's own attribute set.  See admin > catalog > manage attributes > attributes

When you creating or edit attribute, you can specify "Show on Product View Page" to be "Yes".
Comment: I think this would be more complicated than using new attributes. It'd be more like having more instances of a group of attributes (not like an attribute set that can get used only once). Example, I'd have a set of fields that would have "instruction" , "image", "link" as "instruction group". I may need to have multiple instances of this group for a product with ability to add or remove said instances at will.
Comment: What about grouping attributes by tabs like at our site http://amasty.com/magento-abandoned-cart-email.html ?  Demo links, change log, description they all are just product attributes.


How do I get the closest distance for each element within a point coordinate table from a polyline table?

Question: Postgres: How do I get the closest distance for each element within a point coordinate table from a polyline table? And if this is possible what version of Postgres is this doable.
Comment: I'd recommend that you post a table definition, some sample data and some expected results. It'll mean people don't have to construct this data in order to test possible solutions.
Answer: In the absence of any further details on your tables, your best bet is to install PostGIS, which is the spatial-enablement extension to Postgresql.  PostGIS 2 requires Postgresql 9.1 or higher.  PostGIS 1.x will run on earlier versions of Postgresql but you might as well get the most up to date versions.
Then follow a few tutorials so you can cast your tables as GIS point and line features (unless they are already are like that - it's not clear from your post at the time of writing).
Once you have your data and PostGIS set up, use ST_Distance.  You could skip the paragraph above and do it all in the ST_Distance sql command using one of the ST_GeomFromXXX (substitute format for XXX e.g. ST_GeomFromText) but that would mean a more complex SQL command (your call). Just be careful with your projections and coordinate systems (which is why a tutorial is useful if you're not familiar with GIS - which is what I am guessing from your query).
Comment: Looking at the command:
Comment: Looking at the command:float ST_Distance(geometry g1, geometry g2);
and the example:SELECT ST_Distance(
  ST_GeomFromText('POINT(-72.1235 42.3521)',4326),
  ST_GeomFromText('LINESTRING(-72.1260 42.45, -72.123 42.1546)', 4326)
 );
to do it for 2 tables one point and the other polyline would I do it this way?  SELECT ST_Distance(select the_geom from pointtable, select the_geom from polylinetable);  This would output the distance of all the points from the polyline table.  Correct?


Expand superspace function into component form

Question: In 2D (1,1) superconformal field theory, the invariant "distance" between two points  $Z_1=(z_1,\theta_1)$ and $Z_1=(z_1,\theta_1)$ in superspace is $$Z_{12}=z_1-z_2-\theta_1\theta_2.$$
My question is how to compute the quantities when the $\theta$ appears in denominator or in square root, for example, how to expand $\frac{1}{Z_{12}}$ into component form?
And how to expand
\begin{equation}
\sqrt{1-\frac{Z_{12}Z_{34}}{Z_{13}Z_{24}}}
\end{equation}
into component form?
Answer: TL;DR: It is defined by expanding in the finite Taylor series of the $\theta$s.
More details:

Recall that a supernumber $z=z_B+z_S$ has a body $z_B\in\mathbb{C}$, which is a complex number; and a soul $z_S$, which belongs to the ideal generated by Grassmann-odd generators.

For any analytic function $f$, the supernumber $f(z)$ is defined via its formal Taylor series around the body $z_B$.
In particular, for the reciprocal function $f(z)=z^{-1}$, this prescription only make sense if the body $z_B\neq 0$ is non-zero.

Point 2 can be generalized, so that if supernumbers $z,w$ share the same body $z_B=w_B$, then $f(w)$ may be defined as a formal Taylor series around the other supernumber $z$.
In particular for a superfield $\Phi(\theta)=\phi_0+{\cal O}(\theta)$ and its lowest component field $\phi_0$, they share the the same body $\Phi(\theta)_B=\phi_{0B}$, so that $f(\Phi(\theta))$ may be defined as a Taylor series (which happens to be finite!) around $\phi_0$.

This generalizes in a straightforward way to several superfields.
Comment: So the equation  \begin{equation}
\frac{1}{z_1-z_2-\theta_1\theta_2}=\frac{1}{z_1-z_2}\frac{1}{1-\frac{\theta_1\theta_2}{z_1-z_2}}=\frac{1}{z_1-z_2}(1+\frac{\theta_1\theta_2}{z_1-z_2})
\end{equation} is right? Since $(\theta_1\theta_2)^2=0$.
Comment: $\uparrow$ Yes.


How can I improve loading times on a static HTML site?

Question: We are working on a website and noticed that the GIF images(100kb - 200kb) are loading very slowly.
The site is a static site with CSS/HTML.
Does any one have any pointers to why the images might be loading slowly?
Would using JPGs improve the performance?
Here is the HTML code for that image:

Answer: They're loading slow because they're huge.  200KB is a very big image file.  I don't know exactly what the going recommendation is for web images, but it's a very good idea to keep them under 50K.
GIF images are not very efficient for photographic images.  You should experiment with other formats like JPG and PNG to see if you can get the same quality with smaller file size.  You should be able to shrink the file size quite a bit while retaining the quality.
Another trick: use thumbnails.  Save two version of each image, one 25% the size (by resolution) of the other.  Your site visitors can click the thumbnail if they want to see more.  This will speed loading times and reduce your bandwidth bill.
Comment: I'm not sure why PNG would be any smaller, given that it uses a similar compression algorithm to GIF (From memory, PNG is LZ77 + Huffman, while GIF is LZW).  JPG might, but that's because it's a lossy format.
Comment: I included PNG based on recent personal experience- I was creating an avatar for another site and the file had to be under 15K.  For some reason, JPG wouldn't go lower than 25K at the lowest quality, but PNG was 8K at the same visual quality. Go figure ;)
Answer: Are your images properly sized?  If you displaying them on your webpage as 300x300 pixels make sure the original image is the same size.
This helps two-fold, one its less data to download, and 2 it doesn't require extra processing power for the browser to resize.  Additionally, the image will look crisper if its the exact size.
As far as the difference between GIF and JPG, (with the exception of transparency, which JPG doesn't support), it boils down to what your image contains.  GIF uses a color table and a map to that color table to store the image, while JPG uses a compression algorith.  So, if you image contains few color variation you will get a smaller filesize from a GIF.  Conversly, if you have a photograph with lots of color variation you'll want to use a JPG.
Answer: Also take a look at YSlow
It will analyze your site for you and tell you where the bottlenecks might be.
Answer: Enable caching for image files (the example below also adds css and js caching) which will ensure users don't download files twice. If you are using apache 1.3 or 2:
ExpiresActive On
<FilesMatch "\.(ico|gif|jpe?g|png|js|css)$">
   ExpiresDefault "access plus 1 year"
</FilesMatch>

It is probably a reasonable idea to enable gzip compression for html and css. In apache 2:
SetOutputFilter DEFLATE

and in apache 1.3:
mod_gzip_on Yes

Answer: It depends on how large the image is, if you're displaying wallpaper-sized images at 100kb, that's not too bad. If you're displaying thumbnails of this size, then you have a problem.
JPEG images are lossy but can be compressed with ease. Depending on how much compression you select, you can really decrease image sizes with JPEG.
Answer: The fastest loaded resource is always the resource that doesn't need to be loaded at all. I.e. apart from shrinking your images to reasonable sizes you should read about HTTP caching.
You should instruct your web server to deliver the responses with proper caching informations so that user agents may reuse local cached versions.
Mark Nottingham wrote a tutorial about HTTP caching. It's a good starting point.
And this is a tutorial about apache configuration on HTTP chaching.
Answer: You should specify the height and width attributes for the img tag, see below for the W3C Schools explanation of why you should do this. And for further info see http://www.codinghorror.com/blog/archives/000807.html for further more radical techniques.

Tip: It is a good practice to specify
  both the height and width attributes
  for an image. If these attributes are
  set, the space required for the image
  is reserved when the page is loaded.
  However, without these attributes, the
  browser does not know the size of the
  image, and cannot reserve the
  appropriate space to it. The effect
  will be that the page layout will
  change during loading (while the
  images load).
Tip: Do not rescale images with the
  height and width attributes!
  Downsizing a large image with the
  height and width attributes forces a
  user to download the large image (even
  if it looks small on the page). The
  correct method is to rescale the image
  with a program, before using it on a
  page.

This is copied from http://www.w3schools.com/tags/att_img_height.asp
Answer: Look into the free tool: Smush It!
It's co-developed by Stoyan Stephanov, Nicole Sullivan (of Yahoo!) and incorporates every tidbit for images from YSlow (from Yahoo!) and the Yahoo Developer Network findings.
It will analyze your image(s) and determine from a set of server side tools what the optimal image type is (e.g. PNG8, PNG24, GIF, JPG, etc.) and also create the optimized image... e.g. even if you feed it a PNG image, it will find the best method to compress it, and "Smush It" to its smallest possible file size.
Then take the output image, and then serve it up from a (cookie-less domain) if you can, preferably on a CDN, with far-future expires headers, with gzip compression.


Are there any guidelines by Apple on what content apple TV app should have

Question: We are in the process of developing app for Apple TV, are there any guidelines that app should be either a video playing or gaming app, can I submit app with just readonly content like an iOS app and still it will be get approved by apple?
Comment: Have you reviewed the Apple TV developer documents?  That's your first place to look for developer-related questions.
Answer: From this link I found the following about the Human Interface Guidelines. There is more info at the link.
Apple TV apps should feel natural and intuitive. Users should instinctively know what to do and where they are at all times. Use the provided layout grids, keep the text legible at a distance, and avoid cluttering your interface with unnecessary visual adornments.
Apple TV uses a focus model for navigation. People use the remote to move through interface elements such as movie posters, apps, or buttons, highlighting each item as they come to it. An element is considered focused or in focus when the user highlights the item but has not clicked it. Make it clear at a distance when something is in focus. Implement expected button behavior so it's impossible to get lost during navigation—clicking an item with the remote takes you deeper into an app's hierarchy, pressing Menu always takes you back.
There is much more info at the link above.
Comment: Ok thanks for the details, I'll go through this link.
Comment: i sure hope it helps you.
Answer: There's so much documentation it's hard to choose. I like the developer app and watching some WWDC videos to get my bearings. Then dive in to the official documentation.

https://developer.apple.com/tvos/
https://developer.apple.com/app-store/review/guidelines/
Comment: Ok thanks I'll go through these links.


Fastest way to check if array is zero

Question: What is the fastest way to check if an entire array is zero? For my case the elements of the array are either 1 or 0 but for reference purposes the general case can also be considered.
Comment: Maybe ``LinearAlgebra`Private`ZeroArrayQ``? I recall that we had a similar question not long ago...
Comment: Ah, here it is. Not a duplicate but related and thus maybe of interest: https://mathematica.stackexchange.com/q/230971
Comment: @Q.P. - `Total@matrix` returns a vector rather than a scalar. Even if you `Flatten` the matrix first, you would also need to use `Abs` to ensure that a zero result indicated that the matrix was all zeroes.
Comment: You could use `Total`?
Comment: @Q.P. `Total` would work but I'm interested in _speed_. It might be the fastest but I don't know.
Answer: LinearAlgebra`Private`ZeroArrayQ seems to do quite a good job. Curiously enough, Statistics`Library`ConstantVectorQ[#] && #[[1]] == 0 & tends to be a little bit faster on my machine.
Answer: I tested the methods from Henrik and got the following timings
linAlgZeroArrayQ = LinearAlgebra`Private`ZeroArrayQ;
statZeroArrayQ =
  Statistics`Library`ConstantVectorQ[#] && #[[1]] == 0 &;
totalZeroArrayQ = Total[#] == 0 &;

n = 10^5;
exactZeros = ConstantArray[0, n];
numericalZeros = ConstantArray[0., n];
exactSparse = exactZeros; exactSparse[[n/2]] = 1;
numericalSparse = numericalZeros; numericalSparse[[n/2]] = 1.;
exactRandom = RandomChoice[{0, 1}, n];
numericalRandom = RandomChoice[{0., 1.}, n];

functions = {linAlgZeroArrayQ, statZeroArrayQ, totalZeroArrayQ};
tests = {exactZeros, numericalZeros, exactSparse, numericalSparse,
   exactRandom, numericalRandom};
results = Table[
   AbsoluteTiming[Do[functions[[j]]@tests[[i]], {10000}]][[1]], {i, 1,
     Length@tests}, {j, 1, Length@functions}
   ];

TableForm[results,
 TableHeadings -> {{"Exact zeros", "Numerical zeros", "Exact sparse",
    "Numerical sparse", "Exact random",
    "Numerical random"}, {"Linear Algebra method",
    "Statistics method", "Total"}}]

For the cases I tested the LinearAlgebra`Private`ZeroArrayQ seems like a clear winner but there might be cases/machines where Statistics`Library`ConstantVectorQ[#] && #[[1]] == 0 & wins.
Answer: You can try the following
AA = {{0, 0}, {0, 0}};
AllTrue[Flatten[AA], PossibleZeroQ]

Fastest way to check if array is zero


Statitical test on count data

Question: I have a questions regarding a statistical analysis of a biologic experiment. In the experiment I have collected imaging data on the duration of contacts between immune cells. We have compared two distinct types of immune cells and their contact time with a third cell type. The duration of contacts was measured in minutes. Now I want to determine if there are significant differences number of contacts that lasted longer than 30 minutes. This gives mit counts for the two cell types. Example: Cell type 1: 23 out of 140 contacts measured; cell type 2: 34 out of 126 contacts measured. Which statistical test do I need to use in this case?
Comment: Why use how many are longer than a threshold of 30 minutes, instead of testing whether the time is greater in one sample than in the other? (You could do so using a t-test or, if the data is non-normal, has outliers, or shows other issues, with a Wilcoxon rank-sum test)
Answer: If I understand you correctly, you have a 2-by-2 contingency table, with one dimension being the cell type, and the other being contact shorter/longer than 30 minutes.
Such as (in R):
<code> Data <- matrix( c( 23, 140-23, 34, 126-34 ), nc = 2, byrow =TRUE )
</code>
You can then test independence by $\chi^2$-test or Fisher-exact test; in the above case they can be expected to yield very similar results.
<code> chisq.test( Data )
 fisher.test( Data )
</code>
$p$-value is around $0.05$.

Statitical test on count data


Heroku postgres ingress - could not connect to server error

Question: Background..
I'm trying to connect to my heroku database externally from a php script and I'm getting a "Could not connect to server" error
The tech..
It's a "crane" production level database, not a shared database.
I'm trying to connect from a php script, running on a shared hosting platform,
The story so far..
I can connect from my local machine and php connection strings that postgres.heroku.com outputs. I can also connect with the psql string so there's nothing wrong with the connection info
.. but when I move that php script to a php server that I have up and running on another host, then i get a "could not connect" error.. Those hosts assure me that there are no restrictions on making external connections from their side.
The code..
$dbconn = pg_connect("host=ec2-54-235-162-154.compute-1.amazonaws.com port=5882 dbname=***** user=***** password=***** sslmode=require options='--client_encoding=UTF8'") or die('Could not connect: ' . pg_last_error());

The error..
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused Is the server running on host "ec2-54-235-162-154.compute-1.amazonaws.com" and accepting TCP/IP connections on port 5882? in /usr/local/pem/vhosts/164125/webspace/httpdocs/scheduled/postgres_vr.php on line 3 Warning: pg_last_error(): No PostgreSQL link opened yet in /usr/local/pem/vhosts/164125/webspace/httpdocs/scheduled/postgres_vr.php on line 3 Could not connect:

Options
I can't find any documentation in heroku about whitelisting an IP address which would be first guess? Any other pointers?
EDIT I just found this thread, which is similar ..
Heroku Postgres Connection from localhost PHP application .. but I have the correct ssl settings enabled as far as I can see.
Here's the relevant section from the phpinfo() on the openssl and pgsql respectively..
OpenSSL support enabled
OpenSSL Library Version OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
OpenSSL Header Version  OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008

PostgreSQL(libpq) Version   8.1.23
Multibyte character support enabled
SSL support enabled
Active Persistent Links 0
Active Links    0

Directive   Local Value Master Value
pgsql.allow_persistent  On  On
pgsql.auto_reset_persistent Off Off
pgsql.ignore_notice Off Off
pgsql.log_notice    Off Off
pgsql.max_links Unlimited   Unlimited
pgsql.max_persistent    Unlimited   Unlimited

Comment: There is no IP whitelisting. Can you connect with `$ heroku pg:psql -a app_name` (using the Heroku Toolbelt)?
Comment: can you confirm your php was compiled `--with-openssl`? you can check via a page with `phpinfo();` Look for
`OpenSSL support`
Comment: Yep, it's enabled alright. OpenSSL/0.9.8b
Comment: Yep, that command works locally.
Comment: Since this works locally with `psql`, I'm removing the Heroku tag, we've effectively ruled Heroku out as the issue.
Answer: this works locally, but not on a separate server.  The error says it cannot make the connection suggesting it never completes the syn/ack handshake.  Since this works from your computer we can eliminate both Heroku and PostgreSQL.  The specific error and scenario suggest it is not PHP.
So it has to be something else.  The first thing I would look at are any firewalls that sit between your server and the internet.  Failing that, check any settings you may have on the AWS EC instance particularly regarding iptables.


Form I-130 approved (Family Preference 4) What next?

Question: My uncle (mother's brother) filed application (I-130 Form) for my mom, dad, brother and I in 2013 Dec. Now, in August 2020, we got the approval letter. I was 15 years old then and now I'm 22. My brother was 12 in 2013 and now he's 19 years old. My question is: How much time will it take for the visa to come? And what are the next steps? I am afraid that we will be aged out of qualifying by the time we would actually get the visa. Many people are quoting here that they got visa after 11 years from approval. Could someone please help?
Comment: In what countries were your mom and dad born?
Comment: They were born in India and we all are currently living in India.
Answer: The current (Sep 2020) visa bulletin shows that for the F4 category for people born in India, visa numbers are currently available for priority dates (i.e. for I-130 filed) before March 8, 2005 (about 15.5 years ago). So if the wait remains the same in the future, you can expect a visa number to be available for your petition in about 2029 (though the wait may get shorter or longer in the future).
Under the Child Status Protection Act (CSPA), the amount of time the I-130 is pending is subtracted from a child's age when determining whether he/she has aged out. In your case the I-130 was pending (i.e. from filing to approval) for about 6 years and 8 months. That means children will age out at an age of 21 + 6 years 8 months = 27 years 8 months. In 2029, you will be about 31, so you will almost certainly have aged out. Your brother will be about 28; depending on how the visa bulletin moves in the future and his exact birthday, it is possible that he might barely make it.
Comment: Thank u so much for the revert back. Actually, we got an update that visa numbers are currently available for priority dates of 2009. Some of my relatives told me that. Do u have any idea about it? Some people say that visa bulletin is not updated. Any idea?
Comment: @PunitK.5: No. The visa bulletin is updated every month, and it is what controls whether consulates can issue immigrant visas or whether USCIS can approve Adjustment of Status. The dates for each category are different.
Comment: Thank you so much :)


Capacitive Sensing

Question: Is there a way that I can make an Arduino or other Micro-controller detect a change in capacitance?
I'm thinking of having a screen on my door that only turns on when you touch the metal door handle.
Answer: Here is a tutorial
http://www.nerdkits.com/videos/halloween_capacitive_touch_sensor/

The actual sensor used to detect the presence of a hand in explained in detail in the video, but here is an overview. Our sensor operates on the same principle that a capacitive touch sensor works on your laptop touchpad. These capacitive touch sensors work on the premise that humans are mostly water. When you get near an electric field you alter the capacitance enough to be noticed by the sensor.
In our system we set up an RC circuit with a capacitor and a resistor in parallel. We use the MCU to charge capacitor up to 5V (a digital high voltage). Then we turn the pin into an input pin, which essentially disconnects that node. This allows the capacitor to discharge through the resistor. The amount of time it takes the capacitor to discharge will be related to the resistor value times the capacitance. We pick a resistor value large enough that the RC time constant is long enough for us to measure with the MCU. In this case 100K ohms worked great. The sensor in this case is two sheets of aluminum foil, one connected to the MCU pin, and one connected to GND. These two sheets create a capacitor that our MCU is charging and discharging. When your hands move between the two sheets, it alters the electric field, and therefore the capacitance of our tin foil contraption. The capacitor therefore takes longer to discharge, and that is detected by the code on our microcontroller!
Answer: Yes.
Simplest way would be to use a high value resistor (1-10M) and follow the instructions on this old arduino forum post: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1171076259
Comment: http://www.arduino.cc/playground/Main/CapSense
Answer: One of the best ways that I've found to measure capacitance is to use an RC circuit. Use a digital I/O port on a microprocessor to charge and discharge the capacitive sensor through a fixed resistor. Start a timer when you begin the charge/discharge cycle. Then use a comparator to detect when the capacitor has fully charged/discharged. Stop the timer when the comparator trips. The value stored in the timer can then be used to calculate the capacitance of the sensor.
Answer: Not an Arduino specific answer, but Microchip have an explanation of one way to do it on the PIC - which would possibly work on an AVR
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en545264
Only concern with these methods is lack of protection from static discharge
Answer: A capacitive touch sensor can be done without additional hardware. The trick is to enable the internal pull-up of a digital pin, and count the CPU cycles it takes to pull the pin up.
Code and explanation:
http://playground.arduino.cc/Code/CapacitiveSensor
Answer: I prefer taking the analog part of the job away from the microntroller by using the capacitor under test as part of an oscillator and then using the controller to measure puse width.  It is an extra part, but I've had better results this way.

Capacitive Sensing


Which performance measure to use when using SVM: MSE or MAE?

Question: It is a common practice to measure an SVM model's performance by calculating its MSE (Mean Square Error). Why not use Mean Absolute Error (averaging errors' absolute values instead of squared values)?
Comment: Yan, I've merged your two accounts. Please, [register this one](http://stats.stackexchange.com/faq#login) to benefit from Stack Exchange facilities, such as voting, system notifications, commenting, etc. (BTW, it would be good to review your past questions and check whether any of their associated replies deserve some votes or green check--i.e., if one answer solved your problem, mark it as such so that future users will know that it was helpful.)
Answer: Actually, looking at both MAE and RMSE gives you additional information about the distribution of the errors:
$\mathrm{MAE} \leq \mathrm{RMSE} \leq \mathrm{MAE}^2$ (for regression)

if $\mathrm{RMSE}$ is close to $\mathrm{MAE}$, the model makes many relatively small errors
if $\mathrm{RMSE}$ is close to $\mathrm{MAE}^2$, the model makes few but large errors
Answer: The choice of performance metric depends on what is important for the application that you are interested in.  The MSE is a good performance metric for many applications as there is good reason to suppose that noise process is Gaussian.  Sometimes it is better to use the MAE if you don't want your performance metric to be overly sensitive to outliers.  Essentially there is no correct performance metric without knowing more about the nature of the application.
On a different note I am not overly keen on support vector regression, as quite often there is a knowledge about the distribution of the noise in the response variable and we are likely to get a better model of the data if we build that expert knowledge into out model.  That is why we have GLMs rather than just using least squares regression for everything.  The loss function used in SVM does not have a very clear statistical interpretation of this nature.  SVM regression also uses a loss function that is based on a sort of worst-case bound on the error, so if you use a performance metric that is essentially an average case statistic, then that suggests you should instead use a model based on average case performance rather than worst case (e.g. a GLM).
Answer: MAE is more intuitive than MSE to simply evaluate the overall error.
MSE is easier to handle mathematically for variance analysis. For example, MSE is used to calculate the error variance $s_e^2$, which is a recurring value in regression statistics.


Is it physically meaningful to talk about the arrow of time in other universes?

Question: The arrow of time is a concept that has been around for a while.  In modern cosmology, it has been argued that there may be different arrows of time in other universes.  Since these are also considered to be inaccessible, is it physically meaningful to talk of the arrow of time in other universes?
Answer: If it is physically meaningful to speak of "other universes", then yes it is meaningful to speak of an arrow of time (and any other constructions in physics) in those universes. Taking this logic further, one could think of doing statistical mechanics over an ensemble of universes each with its own arrow of time - sort of like a spin-system - in the hopes that a "common" arrow of time could emerge. This is in spirit with how ferromagnetism emerges in spin-systems. Even though each spin considered individually is randomly oriented, on treating the many-body system we find collective behavior manifest itself in the form of a spontaneous, non-zero, macroscopic magnetization.
Feel free to criticize this answer for its speculative aspects. However, the question itself is in fairly speculative territory to begin with.
Comment: One thing would be to demonstrate that other universes exist. This could maybe be possible through indirect measurements - but I fail to see how a statistical theory of the arrows of time could provide any testable prediction.
Comment: @Sklivvz - or for that matter how a theory of other universes could provide testable predictions. There is recent work claiming that CMB spectrum contains evidence of collisions between our universe and others. I'm not sure of its merits and I don't yet have a clear opinion on the multiverse concept so I'm going to stop talking now.
Answer: The possibilities depends on how diverse the alternative universe can be. Some alternatives may have two or more macroscopic time dimensions, or they may be just euclidean spaces with no time dimension. In that case the concept of arrow of time will not make any sense in those universes.
In other universes which have one time dimension like ours there may be a fixed arrow of time as we (appear to) have. It would make no sense to ask whether it pointed in the same or different direction to ours if there is no direct connection with our universe.
It is also possible that a universe with one time dimension has no discernible arrow of time because everything is perpetually in a high entropy state. One theory is that this would be the natural state in our universe except that for some as yet unexplained reason the big bang singularity had a low entropy that creates an arrow for time. I agree with this view but it is not proven and I don't think there is a consensus.
It may also be possible that a universe has different directions for the arrow of time at different times and places so long as it does not switch directly from forward to backward causing paradoxes. It can switch from backwards to forwards with a low entropy epoch at the changeover, or from forwards to backwards if there is a heat-death epoch between them with maximal entropy that prevents useful information passing.
We don't know the laws of physics well enough to say which of these possibilities can be ruled out on theoretical grounds so they currently stand as just possibilities. There is also a valid philosophical question about whether such questions make sense if we can't observe these universes. Personally I think it is valid to consider them if we have theories that predict the existence of other univserses.
Comment: Very interesting answer.  Thanks !  The "many-fingered" time concept is actually extremely complicated, since we can also add non-trivial topology to the time section alone.
Answer: every universe that qualitatively resembles ours - which certainly includes any universe in a hypothetical "multiverse" where ours may belong - has to have a logical arrow of time. The Universe must know which slices are "input" and which of them are "output". Proofs analogous to Boltzmann's H-theorem then guarantee that the universes also have a thermodynamic arrow of time and the two arrows coincide.
All universes that are in a direct or indirect causal relationship with ours have to have the "same" arrow of time as ours - one that doesn't contradict our arrow of time. It must be possible to define the arrow "uniformly" across the whole spacetime and all of its regions. In particular, one can never mix both arrows of time within the same universe - or the same multiverse. That would be logically equivalent to having closed time-like curves - which are inevitably inconsistencies - because you could get to the future along one arrow and back to the past - which would still be to the future according to another arrow of time.
Evolution by the standard laws, starting with any well-defined slice, automatically preserves the uniformity of the arrows of time even when one allows tunneling and eternal inflation.
Cheers
LM
Comment: Dear space_cadet, I found that other people - not talking about you - usually don't pay attention to rational arguments and proofs but rather ad hominem hints etc. So instead of arguments optimally presented by myself, I choose a preprint by Robert Wald http://arxiv.org/abs/gr-qc/0507094 who argued that the thermodynamic arrow of time - or low entry of the early Universe - can't have a dynamical origin.
Comment: Apologies for the wrong name, space_cadet: fixed. I am not assuming that the arrows coincide. I can easily prove that the arrows coincide, and I have sketched the proof. This is not about any "condensation" or any other "dynamical" mechanism: the coincidence of the arrows boils down to basic logic.
Comment: @Lubos I think you mean "Dear Humble" :) As for what I said in my answer, our conclusions are identical in so far as any "universe" must have an arrow of time. However in order *to keep things completely general* a priori, we cannot assume that these arrows will coincide. Then it is the sort of "condensation" that I propose which will lead to a state with a universal arrow of time and one in which closed time-like curves - which would be seen as purely QM effects in this picture - are suppressed, allowing a "classical" universe(s) to emerge. All very hand-wavy but a comment is not big enough,
Comment: ... for greater detail
Comment: @Lubos - you're right. I might be complicating the issue too much. Maybe this is just because of current my love affair with condensates :)
Comment: Thanks for that link @Lubos. Also unless you prefix my name with an ampersand I am not notified of your responses to my comments.


What is the right way - Bring wellness in life/brings wellness in life

Question: What is the right way to write/pronounce - Bring wellness in life/brings wellness in life, which one is correct word to be used in above sentence bring or brings
Answer: The statement in question is not complete. It can either be bring or brings depending upon what precedes the word.
For example:
Her only goal was to bring wellness in life.
Your good deeds always bring wellness in life.
The above answer is based on pure assumption that the statement is not complete on its own. And not a command.
If command, it should simply be, Bring wellness in life. Thanks.
Answer: I don't know if there is a specific rule regarding this, but to answer your questions, it should be "Bring wellness to life" as is the case for all general statements. E.g. Bring joy to the world/ Treat others the way you wanted to be treated./ Love one another.
Just think of it as having the phrase "you should" at the start.
Comment: I have done a bit of research and the grammatical mood of your sentence is called imperative mood, which forms commands and requests. Imperative imply a second person subject, which is why you shouldn't add 's' after the verb :)


Losing all test coverage when testing individual class

Question: I am writing tests for my apex classes. Usually I can test each test class individually from the developer console.

When I run the idividual test my code coverage is 0% even if the class passed.
My only option is to go through Setup|Apex Classes|Run All Tests

When I edit the test class I lose all my test coverage.
Is there anyway I can set it up so I can test each class individually without losing my entire test coverage and not have to navigate to the Run All Tests?
Answer: I believe you are not storing individual test coverage.
Go to Apex test execution, click options button, make sure you have unchecked store aggregate test coverage.


Connection looks heathy but no Internet

Question: I recently updated Ubuntu 16.04/64 and during several days switched between few networks (I was traveling last week). Now back home and cannot get any Internet connection - neither Ethernet nor Wifi. Whatever I did following the advices on stackoverflow etc, nothing does work. Moreover, after updating the second machine with the same OS lost Wifi connectivity, although Ethernet is working. The disease has the following symptoms:

Connection is easy to setup (both Ethernet and Wifi) and it looks
healthy, but there is no Internet. Reboot/restart does not help.
Ip6 was assigned although I set it to "Ignore".
Some outputs (for Ethernet only setup):

$ ifconfig
enp1s0    Link encap:Ethernet  HWaddr XX:XX:XX:XX:XX:XX
      inet addr:192.168.0.115  Bcast:192.168.0.255  Mask:255.255.255.0

      inet6 addr: XXXX::XXXX:XXXX:XXXX:XXXX/64 Scope:Link

      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

      RX packets:22 errors:0 dropped:0 overruns:0 frame:0

      TX packets:45 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1000

      RX bytes:3455 (3.4 KB)  TX bytes:5608 (5.6 KB)

lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0

      inet6 addr: ::1/128 Scope:Host

      UP LOOPBACK RUNNING  MTU:65536  Metric:1

      RX packets:577 errors:0 dropped:0 overruns:0 frame:0

      TX packets:577 errors:0 dropped:0 overruns:0 carrier:0

      collisions:0 txqueuelen:1

      RX bytes:39066 (39.0 KB)  TX bytes:39066 (39.0 KB)

$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         gateway         0.0.0.0         UG    100    0        0 enp1s0
link-local      *               255.255.0.0     U     1000   0        0 enp1s0
192.168.0.0     *               255.255.255.0   U     100    0        0 enp1s0
$ ping 188.8.131.52
PING 22.214.171.124 (126.96.36.199) 56(84) bytes of data.
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
ping: sendmsg: Operation not permitted
--- 184.108.40.206 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2014ms
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
$ iwconfig
lo        no wireless extensions.
enp1s0    no wireless extensions.
wlp2s0    IEEE 802.11bgn  ESSID:off/any
      Mode:Managed  Access Point: Not-Associated   Tx-Power=off

      Retry short limit:7   RTS thr:off   Fragment thr:off

      Power Management:off

$ ping www.google.com
ping: unknown host www.google.com
$ mtr
mtr: unable to get raw sockets.
$ cat /etc/resolv.conf
nameserver 127.0.1.1
search home
I would appreciate step by step instructions how to revive the system. I need to travel once again and full re-installation is the worst option in this case.
Answer: Googling for ping: sendmsg: Operation not permitted suggests that this is probably an issue with iptables blocking outbound packets:
https://serverfault.com/questions/372975/ping-sendmsg-operation-not-permitted-error-after-installing-iptables-on-arch-g

Connection looks heathy but no Internet


When a compound is soluble in a dilute mineral acid, is it necessary that it is also soluble in that concentrated acid?

Question: For example, Barium Phosphate is soluble in dilute mineral acids. Does that also mean that it is also soluble in concentrated form of those acids?
Answer: Well. Barium phosphate $\ce{Ba3(PO4)2}$ is not soluble at all in sulfuric acid $\ce{H2SO4}$ solutions, whatever their concentrations, because it forms barium sulfate $\ce{BaSO4}$ which is an insoluble compound. On the other hand it is soluble in diluted solutions of hydrochloric acid, according to  $$\ce{Ba3(PO4)2 + 6 HCl -> 3 BaCl2 + 2 H3PO4}$$ Unfortunately it is not soluble in concentrated $\ce{HCl}$ solutions, because it produces some barium chloride $\ce{BaCl2}$ which has the strange property of being insoluble in concentrated $\ce{HCl}$ solutions, as the solubility product of $\ce{BaCl2}$ is exceeded.
Comment: Interesting facts that outline what a broad question that is...
Comment: Exceeding the solubility product means just that, it does not mean insolubility; it just informs you what the solubility is. Sodium chloride [saturated] is precipitated by adding gaseous HCl.


Need solution for linux box with two ethernet cards

Question: I need a solution for the problem for the project work.
We have devices, servers and clients working where each device shall have two ethernet cards installed in them. While communicating all the devices should send the data packets through the two interfaces providing the 200% data rate. If one of the card connection fails we can get 100% data rate.
So I made the lab setup for testing before jumping into the project work.
We have kept two servers and two clients in the network, eth0 of all the systems are going to switch1 and eth1 of all systems are going to switch2. There is no physical connection between the two switches.
So while sending can I think I can use iptables to send the any data from the application layer to both the interfaces(Please correct me if Im wrong)
But at the recieving end, we may or maynot get the duplicate data from the same host. I dont think at the recieving end we cant use iptables because the packet will have different ipaddress in their packets.
Do we have anyother method to overcome this one. Please help me it is very urgent I need to give some solution.
Comment: duplicate: http://serverfault.com/questions/199779/redundant-network-handling-in-linux-box
Answer: What you need to do is BOND your interfaces to a single switch..
Or use a routing protocol such as STP (spanning tree protocol)
Most decent switches support this..
I would attempt to play with LACP (Link Aggregation)  IEEE 802.3ad
Here is a wiki to explain
http://en.wikipedia.org/wiki/Link_Aggregation_Control_Protocol#Link_Aggregation_Control_Protocol
Comment: Thnks for the reply, I have used the bonding, but I should keep both the interfaces to two different switches. and there should not be any physical and virtual connection between the two switches. Any more ideas on this???
Comment: The problem you have is that you want the best of both worlds..
Speed and redundancy..
Speed = Bonding/Multiplexing
Redundancy = 2 switches that arent connected.(Need STP)

STP basically will shut down a link by looking at the routing tables to ensure redundancy and no loops. You cant Bond to separate switches without some serious hardware changes.

I would suggest you use gigabit ethernet and STP for redundancy..
If your flooding a link through a redundant switch, buy a new NIC to bond those seperate links.. :D
Depending on your type of traffic, maximising a gigabit will take some effort
Answer: I have a similar setup for the purpose of redundancy. The simplest way to achieve this is to just bridge the two physical interfaces. Then, if one of the cables get cut, it will continue to work. Just remember to include STP even if there is no possibility of a loopback. How you do the bridging depends on the distribution that you are using.
Answer: But in your case, if both are active u r using only one and if failed u r taking another active one.. so anytime u r using only one interface
but my case I have to use both the interfaces while sending the data..
Can you please correct if I can use the same briding concept.. with iptables stuff..
Comment: Either edit your original question, or add information as a comment next time.


How do we know/prove a complex power series converges? and how do we get the domain of convergence?

Question: I'm looking up definitions but I fail to visualize this. I understand how to do Taylor/Laurent expansions and how to find the radius of convergence but I don't know if a series converges or not in the first place. I cannot visualize it when I look at its function. I haven't done it for real numbers because I come from the French system where we haven't done Taylor expansions in high school contrary to the American system, I just learnt this now in my complex analysis class but I'm lost. Any general help to understand convergence would be appreciated!
Comment: See "Finding the Radius of Convergence": https://en.wikipedia.org/wiki/Radius_of_convergence .
Comment: Thank you, I'm more confused about the domain of convergence though. Does it simply mean the disk of center z0 and radius the radius of convergence?
Comment: It depends on the point you pick.  $$f(z)= \sum_{n \geq 0} a_n(z-b)^n$$ is a series about the point $b$, so if the radius of convergence is $R$, then $f$ converges for all points less than $R$ away from $b$.
Comment: You think American students know Taylor expansions from high school?
Answer: If it helps with the understanding, I think an intuitively understanding is good.
We know by definition that the Taylor series is equal to the power series at $x_0=0$, however, if $x_0\neq 0$ one can just substitute. I give an example;
We have the function $f(x)=x^{-1}$, which can be written as:
$$f(x)=\frac{1}{x}=\frac{1}{1-(1-x)}=\sum_{n=0}^\infty(1-x)^n$$
for $|1-x|<1$, as it is a geometric series then. Which we can write as (which is the power series):
$$\sum_{n=0}^\infty (-1)^n(x-1)^n.$$
We can then define $y=x-1$, so
$$f(y+1)=\sum_{n=0}^\infty (-1)^n y^n$$
Where the last then is the Taylor series to the power series we had preivous, as the last one is evaluated at $x_0=0=y+1$.
With the above understanding, we know that a complex power series can be expressed as:
$$\sum_{n=0}^\infty a_n(z-z_0)^n$$
on the domain $B=\left\{z||z-x_0|<r\right\}$. We know that it can only converge if it has the radius $r$, as the sum will just diverge. This can be seen together with the relationship between Taylor and power series.
To find the domain, one can often use the quotient test, if it is positive series, Leibniz + some other test, if alternating, or just Cauchy-Hellman, to find the domain of convergence. There are many methods, but these are those I most often see.


How was wall Rose breached in season 2 of Attack on Titan?

Question: In Season one of Attack on Titan, everytime titans were about to breach a wall, if I understand correctly, they breached a city located in the edge of the wall first, and through that city, they breached the wall. In episode one of the second season of Attack on Titan, it is said wall Rose was breached but I couldnt hear anything about how they entered. is it known? Did they attack a borderline city first?
Answer: Heavy Spoiler!!

 The wall hasn't been breached. The titans didn`t came from outside the wall but have been created inside the wall.  This should be answered in one of the next episodes and has been shown in the 38. chapter of the manga.
Answer: The Wall Rose invasion (spoilers)

started when Zeke invaded Ragako and turned the villagers into mindless titans either through serum or his ability and let them wander through Wall Rose. Through investigation no breach was found in the wall therefore Zeke snuck in instead of breaching it.


Does windows have performance counters to measure statistics of a dialup connection?

Question: Does windows have performance counters to measure statistics of a dialup connection? Opening up Perfmon I can see that it has a performance counter called "Network Interfaces" which can be used to collect stats on a chosen network interface (mostly LAN cards) but I cannot see my dial up connection in the list here. How do I go about collecting stats like bytes sent/received, speed etc for my dial up connection (which is actually a high speed broadband connection!) What is the perfmon query string I need to use?
Comment: I know, I know :) but its not really a dialup! The EVDO broadband modem I am using is connected as a USB dialup modem (USB in RS232 emulation mode)
Answer: Ok finally got a solution...the windows Dialup API is known as RAS for some reason. Windows vista has several performance counters for RAS services. You can get the required information by reading these counters. Refer "RAS total" and "RAS Port".
Answer: You should take a look at the IP helper API functions:
http://msdn.microsoft.com/en-us/library/aa366073%28VS.85%29.aspx


Reactivity in electrophillic substitution

Question: When comparing maximum reactivity of a compound in electrophillic addition, what factors are kept in mind while comparing propene and trans-2-butene?
Why is trans-2-butene more reactive in this case than propene?
Answer: For electrophilic substitution, naturally we look for a greater electron density over the molecule. In trans-2-butene, the are two methyl groups which increase electron density over the pi bond whereas in propene there is just one methly group. In case you don't already know, alkyl groups ($R-$), increase electron density over the bonded atom. This is generally known as inductive effect.


Why is it so difficult to obtain the spectral properties related to infinite matrices, especially when they are not symmetric?

Question: I believe most of the spectral theory is revolving around the bounded self-adjoint linear operators being analogous to real symmetric infinite matrices. Whereas, there are cases when the matrices are not real or symmetric. How can one find its eigenvalues, eigenvectors etc? And what information about the matrix can be obtained from the eigenvalues.
Comment: General bounded linear operators are much less similar to matrices, which makes the analogy rather weak. For instance, there are bounded linear operators with no eigenvalues, such as $f \mapsto (x \mapsto x f(x))$ on $L^2([0,1])$.
Comment: ... and that happens to be a self-adjoint bounded linear operator.  Perhaps more to the point are compact normal operators, which do always have a complete set of eigenvectors.
Comment: Am I right in saying that the anology depends upon the space on which the operator is acting? of course, an operator may or may not have eigenvalues.
Answer: Carleman-matrices, for instance, are of infinite size and systematically not symmetric, and some interesting cases are also complex.
For instance, consider the map
$$ f_m: x \to (1+x)^m - 1 $$
where we assume some fixed $m$. This has a Carlemanmatrix, say "$F_m$" (I always use them in the lower triangular form) and let's denote that relation as
$$ F_m:: \qquad x \to (1+x)^m - 1 $$
Now the given map can be seen as a composition of maps
$$ x \to  \exp( m \cdot \log(1+x))-1$$
and each of that partial maps have their own Carlemanmatrix, say
$$ \begin{array} {rl} S1:: & x \to \log(1+x) \\
 D_m :: & x \to m \cdot x \\
 S2:: & x \to \exp(x)-1 \\
\end{array}$$
Here the matrix $D_m$ is diagonal and the matrices $S1$ and $S2$ are triangular and are also their mutual inverses (just because $\log(1+x)$ and $\exp(x)-1$ are inverse maps).
By the construction we would write
$$ F_m = S1 \cdot D_m \cdot S2 = S1 \cdot D_m \cdot S1^{-1} $$
which has the structure of a diagonalization, just like in the case of matrices of finite size.
The eigenvalues are the consecutive powers of $m$: $$D_m = \operatorname{diag}([1,m,m^2,m^3,...])$$ and the eigenvectors are the columns of the matrix $S1$, which is the matrix of Stirlingnumbers 1st kind, similarity-scaled by the factorials (see for instance Abramowitz&Stegun for this). ($S2$ of course is the matrix of Stirlingnumbers 2nd kind, in the same way similarity-scaled by factorials)
Note, that because $\exp(x)=\exp(x+k \cdot 2 \pi î) \qquad, k \in \mathbb N$ we can have multiple "versions" of $S1$ - just the Carlemanmatrices for $\log(1+x)+k \cdot 2 \pi î$ and so the construction of eigenvectors is not unique (we might then declare the given example as "principal solution").
I've asked here in MSE a question concerning another Carleman- and diagonalization-problem, see:
Question on terminology on diagonalization

[late update]: I had posted an answer in mathoverflow which gives another interesting example for the ambiguity/non-intuitiveness of eigenvalues/-vectors of infinite-sized matrices. See here.
It goes like this:
One simple example with a special matrix, which has somehow "a continuum" as eigenvalue...
Consider some function $ f(x) = K + ax + bx^2 + cx^3 + ... $ having a nonzero radius of convergence. Then think of the infinite matrix of the form
$$ \small  \begin{bmatrix}
  K & . & . & . &  \cdots  \\\
  a & K & . & . &  \cdots \\\
  b & a & K & . & \cdots  \\\
  c & b & a & K & \cdots \\\
 \vdots & \vdots & \vdots& \vdots  & \ddots
\end{bmatrix} $$
From the properties of finite matrices we would expect, that K is an eigenvalue. But consider a type of an infinite vector
$$ V(x) = [1,x,x^2,x^3,x^4,\ldots ] $$ with a scalar parameter $x$ from the range of convergence, then
$$ V(x) \cdot F = f(x) \cdot V(x) $$
This means also: any vector $V(x)$ is an eigenvector of the matrix F and corresponds to the eigenvalue $f(x)$. If now $f(x)$ is entire, for instance the exponential function $ f(x)=\exp(x)$, then any value from the complex plane (except $0$ because $\exp(x)$ is never $0$) "is an eigenvalue" of F contradicting the "naive" extrapolation from the finite truncation of the matrix ...
Comment: @let-me-out: True, and even more: it seems that the diagonalization need not be unique - we had a short discussion about this in the tetration-forum, but I couldn't follow that discussion properly for a longer thread then (so I also don't have an example at hand) I think it was something about the relation of the trace of a matrix to its eigenvalues for the case of finite dimension and this was taken as expectation for the same relation with an infinite-sized Carleman-matrix. I only remember something ambiguous due to this concept...
Comment: This is an interesting example of infinite matrix which is not symmetric, and whose eigenvalues and eigenvectors are obtained by viewing it as a composition of Carlemanmatrices. Thank you.
Comment: But generally it is not easy to obtain structure of a diagonalization of an infinite matrix.


Dice probability with 2 dice

Question: I am needing an answer put in very simple terms so I can then explain to my son hiw to get to said answer!!
The question ;What is the probability of rolling a double six if you threw 2 dice 60 times?
Im not bothered about 'fair' dice etc, just normal 6 sided dice!  I get that there are 36 possible outcomes per roll of two dice. So over 60 rolls there is 2160 possible outcomes. The question is written in the test just as I have written it above. It doesnt allude to simplfying or converting to percentages etc.
All the help you can give would be fantastic thanks
Comment: It is easier to get the complement...that is, the probability that you never get two sixes.  On a single roll, that is $\frac {35}{36}$  so the probability that you never get two sixes in $60$ trials is $\left( \frac {35}{36}\right)^{60}$.  The answer you want is just $1$ minus that.
Comment: Is it rolling *exactly* or *at least once* a double six? I'd guess the latter, and in this case lulu's answer applies.
Comment: Lulu's answer is the definitive answer if the question is about getting two sixes at least once, but if your son is young, you may find that it helps to start with the similar problem of finding the probability of rolling one six when throwing one die a small number of times (one, then two, then three, then generalize).  Of course, the formula for one die is $1 - \left(\frac{5}{6}\right)^n$, where $n$ is the number of rolls.  You can have your son run experiments, collect data, draw graphs...
Comment: BTW, the number of outcomes is $36^{60}$, which is a much bigger number than $36 \cdot 60 = 2160$.  You do care about fair dice, because loaded dice are harder to study.  You also want dice that have no "memory."  If you rolled dice made of dough, which change shape every time you roll them, they would be much harder to study.
Answer: Probability of this question = $1/36+1/36*35/36+1/36*35/6*35/36+...........+1/36*{35/36}^{59}
=1/36 \frac{1-\frac{35}{36}^{60}}{1/36}
=1-\frac{35}{36}^{60}$
Comment: Thanks for all the comments. The question is very vague, nothing else is written other than "What is the probability of rolling a double six if you threw 2 dice 60 times"  We are going to put the question to my sons (who is 12) school teacher and see what he comes up with.

Dice probability with 2 dice


Cannot access shared drive in same machine uisng machine name but can access using IP

Question: I have 4 desktops running Windows Server 2008 32bit version.
I created some shares in all these machines. My program gets files from these machines (like \machine1\abcd). The machine names mentioned in the program and the actual machine names doesn't match and I can't change either program or machine names.
So I mapped the machine name used by the program to the local IP address of the machine using "hosts" file. Everything works fine, but, when I try to access a share in a machine using local machine's name, Windows asks for a username and password. (I tried entering username and password but its not working). But when I try to access the same share using local machine's IP address, its opening.
Let my machine names be m1, m2, m3, m4 and my program refers to them as mb01, mb02, mb03, mb04.
When I try to access a share in mb01 from mb01(m1) as \\mb01\share1, Windows asks for username and password. When try to access shares in other machines everything works perfectly.
I want to access share in local machine without getting prompted for password. How can I achieve that?
Edit 1: I am actually using as \\mb01\share1. Typo in question.
Comment: how about \\mb01\share1 - double slashes
Answer: I just asked a similar question, and someone was able to give an answer that worked!  See this question.
Specifically, you add the registry entry described in this WindowsITPro article, then just restart the Server service.
You cannot ping, because this is strictly a NetBIOS thing, not a TCP/IP thing, but you can now get to your shares using the 'alias' name.


Why does a murderer have to go to an Ir Miklat?

Question: Someone who murdered by accident has to go to the Ir Miklat. I heard that H'shem's intention on commanding so is to put the murderer in contact with the Leviim and to enable him to be positively influenced by them. Is that correct?
Comment: @Shmuel that may be true but it doesn't use that as a reason for the mitzvah
Comment: Related: https://judaism.stackexchange.com/a/103402/27180
Comment: https://www.sefaria.org/Sefer_HaChinukh.408.2?with=all⟨=bi
Comment: @Chatzkel: did not see your comment when I posted an answer.
Comment: @shmuel it would seem that the reason mentioned by the OP is not the one mentioned by the chinuch. He mentioned that the murderer will be influenced by the Leviim. Whereas the Chinuch says it's because they will be accepting of him and treat him well
Comment: @Chatzkel the Chinukh says "that they will never do anything besides [that which is from] the proper path and in line with the truth". This could also help improving the character traits from the murderers, since they would learn from the people in the city they'd live in.
Answer: You're correct. The Sefer HaChinukh (408:2) writes:

And because of the greatness of their stature and the fitness of their deeds and the 'grace of their worth,' their land was chosen over the lands of the other tribes to shelter any one that kills by mistake - maybe their land that is sanctified with their holiness would atone for him.

Further, he writes:

And there is another reason in the thing: Since they are people of known [character] in virtues of disposition and respected wisdoms known to all, they would not loath the killer being saved with them and they would not touch him; and even if he would kill one of their friends or redeemers (relatives) - since he killed him 'suddenly and without enmity.' And about this select tribe is it stated (Deuteronomy 33:9), "Who says about his father and his mother, 'I have not seen him'" - meaning to say, that they will never do anything besides [that which is from] the proper path and in line with the truth; and even [in spite of] the love of father and mother and brothers and sons, which is obligated and compelled by nature, and all the more so [regarding] the love of other people. And I have further written another argument about the matter in the Order of Behar Sinai (Sefer HaChinukh 342).
Answer: In Guide for the Perplexed 3:40 Rambam explains the purpose as follows:

A person who killed another person unknowingly must go into exile (Exod. xii. 13: Num. xxxv. 11-28); because the anger of "the avenger of the blood" (Num. xxxv. 19) cools down while the cause of the mischief is out of sight. The chance of returning from the exile depends on the death of [the high-priest], the most honoured of men, and the friend of all Israel. By his death the relative of the slain person becomes reconciled (ibid. ver. 25); for it is a natural phenomenon that we find consolation in our misfortune when the same misfortune or a greater one has befallen another person. Amongst us no death causes more grief than that of the high-priest.
Friedlander translation


Why is propositional logic not Turing complete?

Question: According to 1 (probably not the most relevant source), propositional logic is not Turing complete. Aren't all computations in computers performed using logic gates, which can be represented as logical operators, though? Is it maybe because logic has no memory while a Turing machine does? What kind of computations is propositional logic unable to perform?
Comment: Yes, but Turing completeness is a theoretical condition, not a practical one. For instance, taking a literal reading of the definitions, the halting problem is decidable for any (idealised) physical computer, because it is a finite state machine!
Comment: Physical computers are not Turing complete either, actually: they only have finite memory, unlike a Turing machine.
Comment: I've heard about this, but they can be considered to be Turing complete for practical purposes, correct? In that they can perform any computation that a Turing machine can up to a memory limit.
Comment: IHMO I think that Tunring's model of computation did not required infinite memory. As far as I remember The original paper talks about "unbounded" tape (see http://eprints.gla.ac.uk/4481/1/4481.pdf?ref=Sex%C5%9Ehop.Com page 3 for a discussion). This means that the length of the tape is unknown a priory but not infinite.
Answer:
Aren't all computations in computers performed using logic gates, which can be represented as logical operators, though?

Using logic gates with feedback. Using only propositional logic it's impossible to express arbitrary repetition, i.e., using the same subformula multiple times. In programming terms, this means no loops, recursion, jumps, or anything similar. Memory is also an issue, but without a means of repetition even with some notion of unbounded memory you'd only be able to use a fixed amount of it.
Propositional logic is among the computationally weakest systems that anyone actually cares about, being unable to even express basic arithmetic (i.e., with numbers of arbitrary size, as opposed to the fixed size of something like an 8-bit adder) on its own.

What kind of computations is propositional logic unable to perform?

Most of them!
As far as Turing-completeness goes, that essentially means "the ability to perform computations which we're not sure will ever finish", but there's a huge range of computations that are known to always finish but which propositional logic can't express.
A good example of another (relatively weak) system that people care about is recognizing regular languages. You can't express this in propositional logic because the input size is variable, and even if you set a hard limit on the input size the best you can do in general is to have a formula that computes a massive OR of subformulas to recognize each possible matching string.
Comment: Thank you for the detailed answer. By feedback you mean sequential circuits, right?
Comment: @Hypercube: I mean circuits where an input to a gate can logically depend on its own output. For example, [flip-flops](http://en.wikipedia.org/wiki/Flip-flop_%28electronics%29) implement simple memory cells using feedback loops.
Answer: "Keep searching until you find an example."
(E.g., is there an even number that is not a sum of two primes?  It's easy to check in each case, so keep going until you meet one.)
Construe the first sentence above as an instruction in a programming language.  It's just that statement that cannot be done in the limited programming language you propose.
One way of defining computability says the computable functions start with the zero function, the successor functions, and the projection functions, and are closed under composition, primitive recursion, and minimalization.  The last operation---minimalization---consists of just searching until you find some specified thing and returning as output the number of steps it takes.   There's a diagonal argument that shows that the functions you get without including minimalization (called the "primitive recursive functions") fail to include all computable functions.  When you add minimalization, you add the risk that the search might run forever.  (In the concrete example above, it runs forever if Goldbach's conjecture is true.)  So you get some functions that are not everywhere defined.  The fact that they're not everywhere defined is just the thing that prevents the same diagonal argument from working on the new class of functions that you get, to show that they also fail to contain everything.


Computation of kernel matrix using radial basis kernel in svm

Question: I want to compute a kernel matrix using RBF on my own. The training data is multidimensional. My query is whether we will apply
$$e^{-\gamma(x-y)^2}$$
for each dimension and then sum the values across all dimension?
Answer: The kernel matrix $K$ or Gram Matrix is a positive-semidefinite symmetric matrix that has the form:
$$ K(x_1,x_2,\dots,x_n) =
\begin{vmatrix}
\langle x_1,x_1 \rangle & \langle x_1,x_2 \rangle & \dots & \langle x_1,x_n \rangle \\
\langle x_2,x_1 \rangle & \langle x_2,x_2 \rangle & \dots & \langle x_2,x_n \rangle \\
\vdots & \vdots & \ddots &\vdots \\
\langle x_n,x_1 \rangle & \langle x_n,x_2 \rangle & \dots & \langle x_n,x_n \rangle
\end{vmatrix}
$$
Where $\langle a,b \rangle$ detones the inner product/dot product of vectors $a$ and $b$ and $\{x_1,x_2,\dots,x_n\}$ is a set of vectors (in this case, training samples).
In order to calculate the Gramian Matrix you will have to calculate the Inner Product using the Kernel Function. For a RBF kernel function $\kappa_{RBF}$ this can be done by
$$K_{ij} = \kappa_{RBF}(x_i,x_j) = e^{\gamma D_{ist}(x_i,x_j)^2} $$
where $\gamma$ is a function hyperparameter, $K_{ij}$ is the element in row $i$ and column $j$ of the matrix $K$ and $ D_{ist}(x_i,x_j)$ is some distance between two vector measured in some vector space.
Usually, the distance measure used is the $L_2$ norm or euclidean distance. Remember that when computing the Kernel function you will use the square $L_2$ norm, so there is no need to take the square root.
There is a open library named pykernels that has implementations to dozens of kernel functions. This here is the implementation for the RBF (or Gaussian) Kernel:
class RBF(Kernel):
    """
    Radial Basis Function kernel, defined as unnormalized Gaussian PDF
        K(x, y) = e^(-g||x - y||^2)
    where:
        g = gamma
    """

    def __init__(self, gamma=None):
        self._gamma = gamma

    def _compute(self, data_1, data_2):
        if self._gamma is None:
            # libSVM heuristics
            self._gamma = 1./data_1.shape[1]

        dists_sq = euclidean_dist_matrix(data_1, data_2)
        return np.exp(-self._gamma * dists_sq)

    def dim(self):
        return np.inf

it uses the square distance define as:
def euclidean_dist_matrix(data_1, data_2):
    """
    Returns matrix of pairwise, squared Euclidean distances
    """
    norms_1 = (data_1 ** 2).sum(axis=1)
    norms_2 = (data_2 ** 2).sum(axis=1)
    return np.abs(norms_1.reshape(-1, 1) + norms_2 - 2 * np.dot(data_1, data_2.T))

The class is defined as a subclass of the Kernel class and has some methods to deal with kernel combinations.
Note that this is not the fastest way to implement euclidean distance, you can do better but this is a simple form to do it. also that "np.abs" should not be needed
Note 2 that this SO Question has a lot of optimized version of RBF Kernel
Comment: Thank you Pedro for the clarification


Why was the MAV crew capsule seemingly designed for re-entry?

Question: In the movie version of The Martian, the MAV's crew module seems to be designed for atmospheric entry. It has a shallow, gumdrop shape, reminiscent of the Apollo or Orion capsules, and what looks like a tiled heatshield on its underbelly. However, in the text of the film, there is no indication that this vehicle was ever meant to re-enter the atmosphere of either Earth or Mars. There's a chance it is carried back to Earth by the Hermes, at which point the crew use it to re-enter and land, but this seems unlikely, as it doesn't have any maneuvering capabilities with which to deorbit, and I would expect the crew to return in the same Orion capsule that carried them to orbit in the first place. I haven't read the book, so perhaps it offers some explanation, or maybe there was something I missed in the movie.
Comment: Didn't the MAV have to aerobrake to reach the surface of Mars?
Comment: @DavidW The whole MAV is softlanded on Mars, so yes, it should have some sort of heatshield protection. But I think the question just refers to the return capsule, at the tip of the MAV. This takes the crew from the Martian surface to orbit, so they can rendezvous with the Hermes. Like the OP, I don't see a good reason for that to have a heatshield.
Comment: @DavidW Right.  The MAV's are prepositioned equipment, sent from Earth before the mission(s).  It would somehow have to be landed on Mars, which would entail entering the atmosphere.
Comment: @CaptAlgorithm I like this answer quite a bit, although being stranded many miles downrange of the Hab in the event of a launch abort seems like a death sentence in itself. All things considered, losing the MAV at all is a death sentence, isn't it? Since NASA seems to not have any rescue plans ready, nor enough supplies to tide over even a singe astronaut until Ares IV.
Comment: Because that's how crew capsule *look* and otherwise it wouldn't look right. It was 100% for cinematographic reasons.
Answer: I can't let this go!  The only answer for the capsule being designed to survive re-entry is cinematographic: That's how we have been trained to think a launch capsule should look. So that's how they showed it.
A failed return to orbit in a MAV capsule would be fatal regardless of whether or not the astronaut survived re-entry. Mark Whatney survived -- just barely -- because when he woke up he had the Mars Hab, provisions for a crew of six, vehicles, a radioisotope generator (and viable potatoes.) The hypothetical crew of six who survived re-entry would have nothing. They would land far, far from anything else and then die. (Probably quickly of suffocation, but if they somehow survived that, it's a toss-up what would get them: accident, starvation, thirst.)
A responsible space agency -- which no matter what its other flaws, NASA certainly is -- would spend the mass wasted here on a re-entry capability on making the actual ascent to orbit more reliable.  (See the Lunar Lander and its return vehicle for a case in point on what actual good engineering does in reality.)
The idea that the capsule would be carried back to Earth and used to land there does not work, either. It is expensive to carry mass to Mars (even with the Hermes) and very, very, very expensive to land it on Mars and then take off with it again.  It would be much, much cheaper and much, much, much safer to send up a return capsule (such as SpaceX's Crew Dragon) to rendezvous with Hermes once it reached Earth orbit.
Comment: Adding to this, theres no reason for the MAV capsule to separate from its service module/booster after MECO - the capsule itself is not large enough to act as its own service module, which means theres basically zero margin of error for docking to Hermes.  Note that the act of separation in the "get Mark Watney to orbit" scenario actually induces a random roll in the capsule as well...  Theres also zero mention of using the capsules OMS system to stabilise the capsule or attempt to change its position even slightly...  Lots of issues in this depiction IMHO.