Convert java.util.date default format to Timestamp in Java

Question: The default format of java.util.date is something like this "Mon May 27 11:46:15 IST 2013". How can I convert this into timestamp and calculate in seconds the difference between the same and current time?
java.util.Date date= new java.util.Date();
Timestamp ts_now = new Timestamp(date.getTime());

The above code gives me the current timestamp. However, I got no clue how to find the timestamp of the above string.
Comment: possible duplicate of [Java string to date conversion](http://stackoverflow.com/questions/4216745/java-string-to-date-conversion)
Comment: I am afraid not, I was working on the timestamp format.
Comment: Duplicate: [Java: Convert String to TimeStamp](http://stackoverflow.com/q/18915075/642706)
Comment: SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy");

This was what I needed..(look at the format type)

However, the link you provided uses

SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");

Wouldn't have worked for my case.
Comment: And duplicate of [this](http://stackoverflow.com/q/4496359/642706) and [this](http://stackoverflow.com/q/15546494/642706) and [this](http://stackoverflow.com/q/4216745/642706) and [this](http://stackoverflow.com/q/20165071/642706) and [this](http://stackoverflow.com/q/16336643/642706) and many more.
Answer: You can use the Calendar class to convert Date
public long getDifference()
{
    SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy");
    Date d = sdf.parse("Mon May 27 11:46:15 IST 2013");

    Calendar c = Calendar.getInstance();
    c.setTime(d);
    long time = c.getTimeInMillis();
    long curr = System.currentTimeMillis();
    long diff = curr - time;    //Time difference in milliseconds
    return diff/1000;
}

Comment: While am trying to convert "Mon May 27 11:46:15 IST 2013" string to date. It gives me an unparsable string exception. Any idea how can I go about?
Comment: thanks a lot @Rahul . I actually combined your answer with Salem's answer above to get this right. Thanks! :)
Answer: Best one
String str_date=month+"-"+day+"-"+yr;
DateFormat formatter = new SimpleDateFormat("MM-dd-yyyy");
Date date = (Date)formatter.parse(str_date);
long output=date.getTime()/1000L;
String str=Long.toString(output);
long timestamp = Long.parseLong(str) * 1000;

Answer: You can use
  long startTime = date.getTime() * 1000000;;
  long estimatedTime = System.nanoTime() - startTime;

To get time in nano.
Java Docs
Comment: How did it convert the string I passed?
Comment: I want to convert "Mon May 27 11:46:15 IST 2013" this string into timestamp. And find the difference between it and the current time..that too in seconds.
Comment: Am s database freak...Java is confusing me.
Comment: Thanks @Nidhin, I found the work around with Salem and Rahul's answer below. Appreciate your quick help. :)
Answer: You can use DateFormat(java.text.*) to parse the date:
DateFormat df = new SimpleDateFormat("EEE MMM dd kk:mm:ss z yyyy", Locale.ENGLISH);
Date d = df.parse("Mon May 27 11:46:15 IST 2013")

You will have to change the locale to match your own (with this you will get 10:46:15). Then you can use the same code you have to convert it to a timestamp.
Comment: Thank you! I used your answer along with @Rahul 's to get this right.
Answer: java.time
I am providing the modern answer. The Timestamp class was always poorly designed, a real hack on top of the already poorly designed Date class. Both those classes are now long outdated. Don't use them.
When the question was asked, you would need a Timestamp for sending a point in time to the SQL database. Since JDBC 4.2 that is no longer the case. Assuming your database needs a timestamp with time zone (recommended for true timestamps), pass it an OffsetDateTime.
Before we can do that we need to overcome a real trouble with your sample string, Mon May 27 11:46:15 IST 2013: the time zone abbreviation. IST may mean Irish Summer Time, Israel Standard Time or India Standard Time (I have even read that Java may parse it into Atlantic/Reykjavik time zone — Icelandic Standard Time?) To control the interpretation we pass our preferred time zone to the formatter that we are using for parsing.
    DateTimeFormatter formatter = new DateTimeFormatterBuilder()
            .appendPattern("EEE MMM dd HH:mm:ss ")
            .appendZoneText(TextStyle.SHORT, Set.of(ZoneId.of("Asia/Kolkata")))
            .appendPattern(" yyyy")
            .toFormatter(Locale.ROOT);
    String dateString = "Mon May 27 11:46:15 IST 2013";
    OffsetDateTime dateTime = formatter.parse(dateString, Instant::from)
            .atOffset(ZoneOffset.UTC);
    System.out.println(dateTime);

This snippet prints:

2013-05-27T06:16:15Z

This is the UTC equivalent of your string (assuming IST was for India Standard Time). Pass the OffsetDateTime to your database using one of the PreparedStatement.setObject methods (not setTimestamp).

How can I convert this into timestamp and calculate in seconds the
  difference between the same and current time?

Calculating the difference in seconds goes very naturally with java.time:
    long differenceInSeconds = ChronoUnit.SECONDS
            .between(dateTime, OffsetDateTime.now(ZoneOffset.UTC));
    System.out.println(differenceInSeconds);

When running just now I got:

202213260

Link: Oracle tutorial: Date Time explaining how to use java.time.


How do I hotwire a vehicle faster?

Question: I'm playing Grand Theft Auto V on Xbox One currently. In Grand Theft Auto IV, if you flicked the left and right triggers very fast while Niko was hotwiring a vehicle, it would complete faster. Is this also a functionality in Grand Theft Auto V? From experimentation, it seems to work on a few vehicles, but I'm not 100% sure. Anyone know if this was implemented?
Answer: Although I couldn't find any official info, I can tell from my experience that this feature does not work anymore. The developers should have implemented this feature in GTA V as well...

How do I hotwire a vehicle faster?


Get Collection of items by pipe separated GUIDs in sitecore

Question: Basically I used multi-list in rendering parameter for an category selection. so i got pipe separated GUIDs of selected item & needs to get a collection of items, is there any method supported by Sitecore api instead of iterating in loop. that could be expensive in terms of efficiency as compare to any built-in Sitecore method.
Answer: There is a MultilistField class in Sitecore.Data.Fields, used as follows
var mlf = new MultilistField(item.Fields["field name"]).
mlf.GetItems();

I don't think it's any more efficient than what you're already doing though. In fact, it probably does just the same internally.
Answer: Another way, avoiding a potential ArgumentNullException (in the case of item.Fields["field name"] being null) is to use Sitecore.Data.ID.ParseArray in combination with a linq statement to get a list of items as follows:
var items = ID.ParseArray(item["field name"])
               .Select(id => item.Database.GetItem(id)).ToList();

Comment: Good point. In fact, this is the way I prefer to do it, and rarely use `MultilistField`. I was just giving the official answer :)


Flow does not read the field 'approval status', is there a workaround?

Question: As things are, Flow does not 'read' the standard approval status of a SharePoint list. I do not want to turn the 'Approval status' into a choice field just to get the Flow working. Is there another way?
Answer: If you are using Microsoft Flow (not SharePoint 2007, 2010, or 2013 workflow) you need to do this:

Remove any SharePoint Approval feature on the list or library and
Remove any existing workflow subscription of any kind exists, i.e.: no 2007, 2010, or 2013 workflow exists for the list.
If you started from a template that includes 'Approval' - start from scratch.

The approval disposition column you speak of is not accessible via Flow.  You have to make a choice: old SP XML workflows or Flow (as of right now).
Flow has its own approval mechanisms built in - that do not rely on a list column because the technology uses  the common data service across all (or at least most) O365 applications.
Therefore the very thing you Do Not want to do is what you must do if you require a column for Approval Status to be visible to end users And desire to use MS Flow.
Edit:
I would instead use a calculated column that relies upon other column(s) to manifest this to the user, but I would not have the flow key off of it.


Why the strange Ubuntu MySQL version?

Question: On my local desktop I'm running Ubuntu 9.04, Jaunty. I've got mysql-server installed, the version is "5.1.30really5.0.75-0ubuntu10.2" that's a very strange version string. Why is it "...really...." ?
Answer: This is the ChangeLog entry from packages.ubuntu.com that first mentiones the name:
mysql-dfsg-5.0 (5.1.30really5.0.75-0ubuntu1) jaunty; urgency=low

  * No change upload. Rebuild so that libmysqlclient15-dev is again available
    in jaunty. mysql-dfsg-5.1_5.1.30-2ubuntu1 provided a libmysqlclient15-dev
    transitional package. -2ubuntu2 doesn't provide libmysqlclient15-dev
    anymore. (LP: #316280).

 -- Mathias Gug <...>  Tue, 13 Jan 2009 13:24:13 -0500

Before that it's name was:
mysql-dfsg-5.0 (5.0.75-1ubuntu1) jaunty; urgency=low

For further details you might want to read up on the Ubuntu Policy (just the first Google hit I got) or even ask Mathias Gug :)
Comment: I guess it is because some other package accidentally depended on mysql-server >= 5.1, and to avoid problems they changed the version number as 5.1.30really... >= 5.1
Answer: It probably means that they took 5.0.75 and ported in the latest security fixes without the enhancements and minor non-security bug fixes.  RedHat used to do that all the time and it drove me nuts because they didn't announce it in the version number like that.
Answer: 5.1.30really5.0.75-0ubuntu10.2 is the Ubuntu package name.
mysql -V

mysql  Ver 14.12 Distrib 5.0.75, for debian-linux-gnu (x86_64) using readline 5.2

So the Mysql version is actually 5.0.75
Comment: Ah yes, I know that's not the 'real' mysql version. I'm asking about the ubuntu package name,

Why the strange Ubuntu MySQL version?


Download Manager with Tor

Question: I would like to know if it's possible to integrate a download manager
with Tor ?
I use Free Download Manager and i want to know if i can change something
in the parameters of Tor to do it possible ?
If it's possible, someone can explain me how ?
Thanks.
Answer: For someone reading in 2023:
Free Download Manager now support Socks5 proxy. To access onion download links, just run a Tor Browser and then add Address: 127.0.0.1 and Port: 9150 in your FDM settings:

After that you can paste onion download links in FDM and it will use socks5 proxy to download files.
Disclaimer: I have zero knowledge of Tor and Proxies, I just found this method while messing with tor settings and FDM settings. I am not sure if this is safe or anonymous. I am sharing because it works, but I dont know at what cost. Someone experienced can probably provide input if this method is okay.
Answer: Well, Tor is JUST a SOCKS proxy - so make it set into the download manager's settings and you're good to go! A separate remark if you're about to use a download manager from dot-onion sites: make sure they're properly locally resolved and routed to Tor's TransPort
Answer: As I've searched HERE, currently FDM does not support SOCKs proxy and it is their TODO list. Therefore you should use some external applications for tunneling the system traffic through TOR (or a specific program) such as Proxifier. You can run TOR browser in order to run the SOCKs proxy on your system, then add the proxy server to Proxifier as below.
.
Then you can add a rule to tunnel FDM traffic through the proxy, as below:

However, Proxifier is not free. You can see list of alternative programs in this link.

Download Manager with Tor


A question on position and velocity vectors from a vector space perspective

Question: In introductory physics we are taught about position and velocity vectors. Though the representation of those vectors is identical (i.e. $x\hat{x}+y\hat{y}+z\hat{z}$) they must belong to separate vector spaces, as it would be nonsensical to add a position vector to a velocity vector. Now, when we multiply a velocity vector by time, what we get is a displacement, and this is addable to position, i.e. $\vec{x}=\vec{x}_0 + \vec{v}t$. This seems odd, as though somehow multiplying by time projects the velocity vector into the position vector space. But all we're doing is multiplying velocity by a scalar. But now we can add the result to a vector that was not in the original vector space. This is not how vector spaces work, per my understanding. What is going on when a velocity vector is multiplied by time, a scalar value, that allows the result to add with a position vector which was not part of the original vector space?
Answer: So my answer is that they are almost the same space $\mathbb R^3$ but not quite.
What is actually happening is that anything you regard as a physics scalar is actually an equivalence class of pairs $(m, s) \in \mathbb R\times\mathbb R_+$ where $(m, s)\equiv (M, S)$ just when $m/s = M/S$. The quantity $m$ is the measurement we actually see and the quantity $s$ is a scale factor which we attempt to determine through a process we call "calibrating our instruments." (In fact there is also a third number here which we call our uncertainty about the measurement, that depends on both uncertainty in $m$ and $s$, but let's ignore that because we can kind of tack it on later just as easily as now and doing it rigorously requires Borel sigma-algebras or the like.)
So for example you measure something with a meter stick and it tells you 100, I measure the same thing with my tape measure and I get a very different number, 39 ⅜, we do not immediately think that the world is broken, rather we think that you are measuring in centimeters and I am measuring in inches. The two are equivalent once we calibrate the meter stick and the tape measure to each other, to arrive at some common base. Moreover, we expect the exact choice of base for this number to not matter much, so we kind of have in the back of our minds a scaling isomorphism separate from the equivalence relation where we could do all the same physics with $(m, \alpha s)$ for some $\alpha$.
Given this alone, $+$ is still well-defined as $P_1+P_2=\{(m_1+m_2,s): (m_1, s)\in P_1, (m_2,s)\in P_2\}$. So like if I had chosen $k s$ I would have ended up with $(k m_1 + k m_2, ks)\equiv (m_1+m_2, s),$ so my equivalence class property is not broken. But $\cdot$ is not because the same approach yields $(k^2 m_1 m_2, k s)$. There are other definitions which work like say $(tm_1m_2/(s_1s_2), t)$ but they violate the scaling isomorphism. To get back our precious multiplication operation, we have to define an even larger space.
Here we assume that there are $n$ fundamental "dimensions" for the fundamental scale factors and we consider an equivalence class of $\mathbb R \times \mathbb R_+^n$. The trick is that we don't have just one of these, we have countably infinitely many, parameterized by a $(q_1,\dots q_n)\in\mathbb Q^n$. So now $(m, (s_1, \dots s_n))\equiv (M, (S_1,\dots S_n))$ just when
$${m_1\over s_1^{q_1}\cdot \dots  s_n^{q_n}}
\equiv{M_1\over S_1^{q_1}\cdot \dots  S_n^{q_n}}.$$
Now each one space has an internal addition operation as before, but now also we have a multiplication operation which connects any two spaces, $$(m, \mathbf s)\cdot (M, \mathbf s) = (m \cdot M, \mathbf s)$$ now works precisely because this lives in $\mathbf q+\mathbf Q$ and, had you chosen $k s_i$, you would have $k^{q_i} m ~k^{Q_i} M/(s_1^{q_1+Q_1}\dots(k s_i)^{q_i+Q_i}\dots)$ and the scale factor divides out cleanly.
You may notice that this trick just requires $\mathbb N$ for the exponent rather than the full power of $\mathbb Q$ and that is true, but defining division requires $\mathbb Z$, and it is very nice to be able to invert from square meters back down to meters so closing this under $n^{\text{th}}$ roots is valuable. Closing under real roots has on the flip side no added value for physicists as far as I know. But especially in electrodynamics with Gaussian units you do get these strange square-roots-of-cm units and so forth.
So I will also say that in practice, most people use the SI units, which have $n=7$ and $q_1$ designates scaling with mass with $m_1=s_1=1$ for one kilogram, $q_2$ with length calibrated to meters, $q_3$ with time calibrated to seconds, $q_4$ with temperature calibrated to kelvins, $q_5$ with amount of substance calibrated to moles, $q_6$ with electric current calibrated to amperes, and $q_7$ with luminous intensity calibrated to candelas. So for example a speed has the vector $\mathbf q = (0, 1, -1, 0, 0, 0, 0)$ and if we want it in kilometers per hour then it has the scale factors $\mathbf s=(1, 1000, 3600, 1,1,1,1)$ and in practice we denote the both of these as $\text{km}/\text{hr}$ in one go rather than trying to write out these two abstruse 7-component vectors.
This is all to say that when you create vector spaces on top of these scalars, you have a similar situation of networked vector spaces indexed by a $\mathbb Q^n$, and while there is a field of scalars with $\mathbf q=0$ which you can lean on now, this variable $t$ is not one of them, it has a non-zero $\mathbf q =(0,0,1,0,0,0,0)$ and therefore a scalar multiplication with it takes the space $(0,1,-1,0,0,0,0)$ to the space $(0,1,0,0,0,0,0)$ which is indeed a different vector space.
We do teach all of this but never at this level of rigor, you are much more likely to just see the named units and you are told that you cannot add two numbers unless those units are exactly the same, and you are told that they multiply like numbers but are not numbers, and you are hopefully told, although I am finding this less and less, that if you have an equation among units, say $1000\text{ m}=1\text{ km},$ or $3600\text{ s}=1\text{ hr},$ that you can use that to substitute: in this case if you had a car driving at $72 \text{ km}/\text{hr}$ you can substitute both of those units as $72\cdot(1000\text{m})/(3600 \text{s}) = 20 \text{m/s}.$
One advantage of this level of rigor is that I can tell you the fundamental idea of dimensional analysis, which is that because you can't add scalars with different $\mathbf q$, and because a Taylor series of an arbitrary smooth function would add terms with different powers, you can only take an arbitrary smooth function of a dimensionless quantity $\mathbf q=0$. This in turn creates a linear algebra problem: I know that these five quantities are the only ones that are physically relevant for this problem, I know each of their $\mathbf q_1\dots\mathbf q_5$, what are the independent linear combinations which are dimensionless? Then an arbitrary answer must be, always, some combination of the five parameters which has the right units, times an arbitrary function of the dimensionless combinations.
So for example if you want to know the radius of curvature of a particle moving with velocity $v$ and acceleration $a$, well you are asking for a length and I have a length per unit time and a length per unit squared time, it has to be $k v^2/a$ for some pure number $k$. Turns out $k=1/\sin\theta$ where $\theta$ is the angle between the vectors, dimensional analysis can't tell you that, but you got 90% of the solution "without thinking about it."
Answer: Who says they are separate vector spaces? You are thinking of quantum mechanics where position and velocity (momentum) belong to separate vector spaces. In classical mechanics this is not the case and in the example you provide above, both vector spaces are the same. You do not add position to velocity because they are different quantities and have different physical dimensions.
What you are confusing are the abstract (Hilbert) vector spaces we deal with in QM. In classical mechanics we are dealing with real actual dimensions given by the unit vectors i j k which "span" (define) physical (not abstract) space. So that we can add velocity and position (by using t multiplication) within that very same space.
Comment: I must be fundamentally misunderstanding something, and if you could help me understand what I would appreciate it. If position/displacement and velocity are on the same vector space then then one must be addable to the other, by definition. What would be the interpretation of such an operation? Would higher derivatives also belong to the same vector space?
Comment: Yes. What you are confusing are the abstract (Hilbert) vector spaces we deal with in QM. In classical mechanics we are dealing with real actual dimensions given by the unit vectors I j k which span physical (not abstract) dimensional space. So that we can add velocity and position (by using t multiplication) within the very same vector space.
Answer: What you have discovered is that "position" doesn't really live in a vector space, it lives in an affine space. Of course there are technical abstract definitions of the two, but what it boils down to is the origin.
Vector spaces don't really have one, though there is a unique null vector, $\vec 0$, that satisfies:
$$ \vec a + \vec 0 = \vec a $$
for instance. Meanwhile, the coordinate ${\bf O} = (0, 0, 0)$ is not special, and depends entirely on your choice of coordinates.
To define the position of a point, you need to define the origin and some displacement vector:
$$ {\bf A} = {\bf O} + \vec r_A $$
One can add a vector to a point to get a new point:
$$ {\bf A} +\vec r_{B-A} = {\bf B} $$
and you can subtract two points to get their vector difference:
$$ {\bf B} - {\bf A }=\vec r_{B-A} $$
but you cannot add two points:
$$ {\bf A} + {\bf B }=?$$
in a coordinate independent way.
Comment: Perhaps the question should be rephrased in terms of displacement vectors rather than position vectors, then?


Realizable automorphism groups of graphs

Question: Frucht's theorem states that every group can be realized as an automorphism group of a graph.  I am interested in which subgroups of $S_n$ can be realized as an automorphism group of a graph on $n$ vertices.  Are there any things we can say about these groups or their actions which don't tautologically follow from the definition of automorphism groups of graphs?
Comment: Do you consider graph as oriented? Or you view them as a (reflexive?) incidence relation? Do you allow selfloops/multi-edges? In addition, you probably require that the action on the $n$ vertices is the given original permutation action. The answer to the question "Which subgroups of $S_n$ are equal to the automorphism group of a graph structure on $\{1,\dots,n\}$ is highly sensitive to these details.
Comment: Now as regards the question, does it mean anything else than "what can we say that is non-trivial"? I think you could include some context, and possibly some trivial examples. In this kind of question, there can be somewhat trivial observations, and when thinking about such a question I like to have other preoccupations than "is this thing considered as trivial by the OP". In any case, if you think a little about your own problem, you can end up with some more precise and well-thought question.
Answer: A graphical regular representation (GRR) of a group $G$ is a Cayley graph $X$ such that $\mathrm{Aut}(X)\cong G$. We know that if $|G| > 32$ and $G$ is neither abelian with exponent greater then two, nor generalized dicyclic,
then $G$ has a GRR. A generalized dicyclic group is a non-abelian group that admits an automorphism that maps each element to itself or its inverse; they necessarily have an abelian subgroup of index two. (There is an explicit presentation.)
If $G$ is cyclic with order a prime power $q$ and $G$ acts as a group of automorphisms of a graph $X$, then $G$ must have an orbit of length $q$. f $|V(X)|=q$, then $X$ is a Cayley graph for $G$ and $|\mathrm{Aut}(X)| \ge 2q$. So cyclic groups of prime power order $q$ cannot be realized as automorphism groups of graphs with at most $q$ vertices.
Babai (On the minimum order of graphs with given group https://cms.math.ca/10.4153/CMB-1974-082-9) shows that
if $G$ is not cyclic of order 3, 4 or 5, then it is the full automorphism group of a graph with at most $2|G|$ vertices.
We can use this to realize more groups as automorphism groups of small graphs. For example if $G$ is cyclic of order 63, take the disjoint
union of graphs on 14 and 18 vertices (with automorphism groups cyclic of
order 7 and 9 respectively) along with an asymmetric graph on 41 vertices
to get a graph on 63 vertices with automorphism group isomorphic to $G$.


Prove that $\int_S\left(d\vec\sigma\times \vec\nabla\right)\times \vec P=\int_{\partial S}d\vec r\times \vec P~.$

Question: Prove that $$\int_S\left(d\vec\sigma\times \vec\nabla\right)\times \vec P=\int_{\partial S}d\vec r\times \vec P~.$$
Can someone help me with this problem? I'm having troubles with using the correct identities to get the answer.
Answer: A good way to deal with these things is to learn how to use the Levi-Civita symbols, but since you are asking this question I will assume you are not familiar with it.
Another good idea is to simplify by making your expressions scalar. Let there be some unit vector $\mathbf{\hat{a}}$ that is pointing in the same direction everywhere. I will use bold-face to denote vectors. You can have $\mathbf{\hat{a}}=\mathbf{\hat{x}}$ or $\mathbf{\hat{y}}$ or $\mathbf{\hat{z}}$ or any combination of them.
Consider:
$$
\mathbf{\hat{a}}.\int_S d^2 r \: \left(\mathbf{\hat{n}}\times\boldsymbol{\nabla}\right)\times \boldsymbol{P}
$$
Where $\mathbf{\hat{n}}$ is the unit vector normal to the surface $S$, whilst $d^2 r$ is the surface element (in your notation $d\boldsymbol{\sigma}=d^2 r\: \mathbf{\hat{n}}$).
The neat thing about $\mathbf{\hat{a}}$ is that it is constant, and so can be taken in and out of the integral as well as the derivative. You can then show (try it component by component if you wish):
$$
\mathbf{\hat{a}}.\left(\mathbf{\hat{n}}\times\boldsymbol{\nabla}\right)\times\boldsymbol{P}=-\mathbf{\hat{n}}.\boldsymbol{\nabla}\times\left(\mathbf{\hat{a}}\times\boldsymbol{P}\right)
$$
It follows that:
$$
\mathbf{\hat{a}}.\int_S d^2 r \: \left(\mathbf{\hat{n}}\times\boldsymbol{\nabla}\right)\times \boldsymbol{P} = - \int_S d^2r \: \mathbf{\hat{n}}.\boldsymbol{\nabla}\times\left(\mathbf{\hat{a}}\times\boldsymbol{P}\right)=-\int_{\partial S} dl \:\mathbf{\hat{l}}.\left(\mathbf{\hat{a}}\times\boldsymbol{P}\right)
$$
Where $dl$ is the arc-length element and $\mathbf{\hat{l}}$ is the tangent vector. All you need to do now is to re-arange $\mathbf{\hat{l}}.\left(\mathbf{\hat{a}}\times\boldsymbol{P}\right)\to\mathbf{\hat{a}}.\left(\mathbf{\hat{l}}\times\boldsymbol{P}\right)$, and take $\mathbf{\hat{a}}$ out of the integral. Since it is valid for any $\mathbf{\hat{a}}$, it is valid as a vector identity.


Django: FileNotFoundError: No such file or directory

Question: I'd just like to check if my Django model works or not(By trying create a new model instance on admin page). However I get FileNotFoundError at /admin/appname/modelname/add/ [Errno 2] No such file or directory: '/home/user/PycharmProjects/myproject/media/file_I_wanna_upload.file' (It's an absolute path where the uploaded file should be situated after saving my new model instance).
In my settings.py:
MEDIA_ROOT = 'media'
MEDIA_URL = '/media/'

In my project's urls.py:
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
                  path('admin/', admin.site.urls),
                  ...
              ] + static(settings.MEDIA_URL,
                         document_root=settings.MEDIA_ROOT
                         )

And finally my models.py
from PIL import Image as I

class Image(models.Model):
    galery = models.ForeignKey(Galery, on_delete=models.CASCADE)
    image = models.ImageField(upload_to='photos')

    def save(self, *args, **kwargs):
        img = I.open(self.image.path)
        img.resize(size=(300, 300))
        img.save(self.image.path)
        return super(Image, self).save(*args, **kwargs)

Everything seems be working good. However it doesn't.
Here is another model that I have no problems with:
class UserProfile(models.Model):
    user = models.OneToOneField(CustomUser, related_name='userprofile', on_delete=models.CASCADE)
    username = models.CharField(max_length=30, unique=True)
    slug = models.SlugField(unique=True)
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=30)
    avatar = models.ImageField(default="default.png", upload_to='avatars', blank=True)
    description = models.TextField(max_length=10 ** 4, blank=True)

    def __str__(self):
        return self.username

    def save(self, *args, **kwargs):
        self.slug = slugify(self.username)
        return super().save(*args, **kwargs)

What am I doing wrong? Help me please.
Answer: The issue is that the image.path won't exist until you've saved the instance. You could re-write your model as follows:
    class Image(models.Model):
        galery = models.ForeignKey(Galery, on_delete=models.CASCADE)
        image = models.ImageField(upload_to='photos')

        def save(self, *args, **kwargs):
            super(Image, self).save(*args, **kwargs)
            img = I.open(self.image.path)
            img.resize(size=(300, 300))
            img.save(self.image.path)

This is very similar to the next question: How to get content of Django ImageField before it is saved?


What is the highest score obtainable in Pac-Man?

Question: What is the highest score possible, if you eat all the dots, all the fruit and all the monsters?
Answer: The maximum possible score in Pac-Man is 3,333,360 points, achieved by eating every single dot, energizer blob, flashing blue ghost and fruit on 256 boards.  This has been achieved several times since 1999.
Comment: Pity. 27 points too many.
Comment: just as a pointer for intrested people passing though, you can see **why** that is, here: http://gaming.stackexchange.com/questions/185772/why-is-3333360-the-maximum-score-in-pac-man/185776#185776
Answer: The highest score possible is 333,333,360 if you eat all the ghosts in the first 18 levels and eat all items in all levels. And the nine dots in the kill screen(level 256) board.
Comment: Where do these extra 330 million come from that aren't in the other answer?
Comment: This doesn't add anything new to a question that's nearly 8 years old


Help.. Black mold growing from seam in 2 peice tub/shower stall

Question: I'm a property manager and my company aquired a new condo about 9 months ago.  Upon inspecting the unit today I noticed a line of black mold under this ledge in the shower.. The ledge is apparently a seam where the shower wall attaches to the lower portion of the stall/bathtub.  This seam does not appear to be well sealed.. There is evidence of some caulking having been done at some point but it's deteriorated and in no way is it providing a watertight seal along this seam.. Some lengths of it have no visible caulking but a noticable gap between the pieces. The mold is also growing out of the overflow hole in the drain stopper and creeping from around the faucet fixture ..I am thinking the area surrounding the shower stall inside the walls is soaked.. Rotting and full of black mold.. I'm going to guess that caulking the seam and the fixtures and pretending I know nothing is not an option.. What are my options and how bad could this be? I do have a moisture meter that you stab into the drywall and also have a snake video camera thing... What do I do..I need some answers ideas and solutions before I approach the owners with this news... Please help!!
Comment: Having the mold tested for type might be an idea.  There are thousands of types, but a few do have very negative health concerns.  Being more of a commercial business, depending on type of mold might lead to big lawsuits if not taken care of the right way.  Adding a bit of sealer and washing what you can see might not be good enough.
Answer: Pictures here would help, but I believe I am familiar with the type of tub/shower enclosure you are speaking of.
The wall panels overlap the tub flange by about 2-3 inches. Some manufactures do not recommend caulking, as water intrusion is unlikely during normal use. So lack of caulk does not mean there is reason to expect a problem.
The black mold may simply be the result of soap scum collecting in those areas providing the mold spores something to grow on. this is especially true if the unit was vacant and unused for months. (I have purchased homes with baths in this type of condition. Torn out showers and such to remodel and found no problem behind them.)
That said; Your due diligence would dictate that you remove the trim from the control valve and use your camera snake to see what is behind that panel. If the result is negative for water leaks and mold issues, you have done what a reasonable person could be expected to do. If there are signs of mold or water then of course repairs and remediation are required.
Good Luck
Answer: I agree that this seems to be a "moisture behind the enclosure" problem. I think the main question is what is the entry point of the water? Is it coming in high and running down? Is it coming in at the bottom and washing in and out like the tide when the shower is used? Is it a vertical seam leak? Is it a completely external leak, maybe coming from the roof (yea, that's a long shot).
Your camera and moisture meter will help you find that answer. If it's limited to a leak at the bottom, might be salvageable. Depends on the extent of the damage and your ability to access the area to clean up and repair. If it's just surface mold, you can use a mild bleach solution to kill the mold, scrape it out and reseal the seam. I like to lay in paper towels and then soak them with the bleach solution using a spray bottle. That controls the bleach better and reduces splashing.
You might have some success in removing the two piece enclosure and reusing it. Depends on the condition and if it gets damaged in the removal. I'd get permission before moving forward on that plan, because the outcome (and cost) can vary.


Petersson-product of the cusp part of the theta series

Question: Who can help me solving this problem: $Q:\mathbb{Z}^{2k}\to \mathbb{Z}$ is any positive definite integer -valued quadratic form in $2k$ variables, then it is  well known, that the thetaseries $$\theta_Q(z):=\sum_{m\in\mathbb{Z}^{2k}}q^{Q(m)}\ (q=e^{2\pi i z})$$ is a modular form of weight $k$ on the congruence group $\Gamma_0(N)$ ( for some integer $N$ ) with some character $\chi$ $\bmod$ $N$, i.e. $$\theta_Q \left(\frac{az+b}{cz+d}\right)=\chi(d)(cz+d)^k \theta_Q(z)$$ for all $\big(\begin{smallmatrix}a&b\\c&d\end{smallmatrix}\big)\in \Gamma_0(N)$. Let us denote the space of modular forms of weight $k$ on $\Gamma_0(N)$ with character $\chi$ by M$_k(\Gamma_0(N),\chi)$. Let S$_k(\Gamma_0(N),\chi)$ be the subspace of cusp forms and $\mathcal{E}_k(\Gamma_0(N),\chi)$ be the eisenstein subspace. We know
$$\text{M}_k(\Gamma_0(N),\chi)=\mathcal{E}_k(\Gamma_0(N),\chi)\oplus\text{S}_k(\Gamma_0(N),\chi)$$ and this decomposition is orthogonal under the Petersson inner product. Let $S=S(z)\in S_k(\Gamma_0(N),\chi)$ be the Cusp part of $\theta_Q$. My Question is: Is there any explicit bound $b=b(N,k,\chi)$ for $\langle S,S\rangle$, where $\langle \dot,\dot \rangle$ is the Petersson-Skalarproduct.
Answer: I don't know that anyone has worked out a completely explicit and completely general bound on the Petersson inner product of the cusp form part of a theta series. There are a number of ways to approach this including the definition, Poincare series, and the approximate functional equation for Rankin-Selberg $L$-functions. Here are some references that may be useful:
$\bullet$ Schulze-Pillot has a paper "On explicit versions of Tartakovski's theorem" that gives an explicit bound in the $2k = 4$ case.
$\bullet$ Duke has a paper that gives some bounds depending only on the discriminant in the ternary case ("On ternary quadratic forms", Journal of Number Theory, 2005).
$\bullet$ Schulze-Pillot's paper was inspired in part by an older paper of Fomenko ("Estimates for scalar squares of cusp forms, and arithmetic applications", Journal of Soviet Mathematics, 1991). You might also take a look at my own paper "Quadratic forms representing all odd positive integers", which will appear next month in the American Journal of Math. In this I study the $2k = 4$ case for quadratic forms of fundamental discriminant, but I stop short of giving a completely explicit bound, even in this case.
$\bullet$ There are some other papers that use analytic methods to study quadratic forms, including papers of G.L. Watson from the 1960s, and the recent paper of Browning and Dietmann ("On the representation of integers by quadratic forms", Proceedings of the London Math Society, 2008).
Comment: Abdullah - Giving explicit lower bounds is difficult when $f$ is a "CM form". This is connected with the problem of $L$-functions having Siegel zeroes. Even in other cases, $\langle f, f \rangle$ can be small. For example, if $f = \Delta$ is usual weight $12$ modular form, $\langle \Delta, \Delta \rangle \approx 9.887 \cdot 10^{-7}$.
Comment: Thank you Jeremy. I have read the paper by Fomenko. He had proven there the case 2k = 4 and that is some time ago, I thought that the general case is probably already proved. The reference of Schulze -Pillot (He is my Mentor for my Masterthesis) was the reason why I looked at Fermenko. You are a great help - now i know it is a difficult problem :)
Comment: Another Question: Do you Know a lower bound b for $$, if $f\in S_k(\Gamma_0(N),\chi)$ is a primitive form? I think $ \ge 1$ for all primitive forms. Is that right?


Recourse for patently unfair make-up exam?

Question: I am a senior finishing dual degrees in chemistry and mathematics and missed an exam in an upper level chemistry course due to a brief hospitalization which was fully documented. I was granted a make-up exam by the instructor along with a few other students. Our exam was 14 pages long, five pages longer than the original, and incredibly difficult in comparison. Several questions were structured in such a way that knowledge of very obscure and minute details from the 800 plus lecture slides and 200 plus pages of text was required. Without exaggeration, the make-up was perhaps 5 or 6 times harder and significantly longer for the same amount of time. I have no doubt that I failed and will be lucky if my score is even 60%. What actions, if any, should I take? I plan to talk the instructor when my grade posts, but I doubt that is going to get me anywhere. After spending at least 48 hours studying in the last two weeks, this feels very defeating.
Comment: I don't have any good advice, i just want to say i'm sorry, you're not alone, and most importantly given time this big deal will be totally insignificant in the grand scheme of your life. Don't lose faith in yourself, your abilities, particularly your ability to determine your own future!
Comment: Country? Please note that it is not easy to make make-up exams that are of the same difficulty than the original.
Comment: Just curious: how do you know the makeup exam was much harder than the original exam if you didn't write the original exam? Is it possible you're just going on hearsay where students who didn't write the original exam jumped to the conclusion that the makeup exam was much harder simply because it was longer?
Comment: _due to a brief hospitalization_  Is this course the only one you're taking this semester? Is this exam the only exam you missed during your brief hospital stay? How long did it take for recovery from the illness? Are you fully recovered yet? What did your medical doctor's documentation/note/letter say? Did your doctor say you are back to 100% functionality? Are you sure the instructor had read the doctor's note? If the answers to the questions above are in your favor, you really should talk to the instructor about it before the grade is posted.
Comment: _I have no doubt that I failed_ You don't get to decide your grade. The instructor does.
Answer: Given that exams are difficult to create, especially make-up exams, it is just possible that it will work out when the instructor sees the results. I doubt that it was any sort of 'retaliation'. Wait for the grades and have a conversation.
It is too early to take action until you see the actual results and their effect.
Let me note that for some sorts of exams, writing intelligently about the problem is enough. If the problems are especially difficult then it may not really be possible under exam constraints to find a proper solution. But if what you write is "sensible", and demonstrates that you have the required knowledge, it may be enough, depending on the person interpreting the results. In any case, it is pretty much impossible to treat the results as "equivalent" to those of the normally given exam. A sensible instructor will recognize this.
Comment: The fact that the make-up exam was five pages longer than the original does seem to count somewhat against the "given that exams are difficult to create" theory. It is, indeed, quite difficult to ensure that a make-up exam is comparable to the original in difficulty, but it's not that difficult for them to broadly be similar in size.
Comment: Sadly, I know a colleague who does this as well. It's a terrible practice, but it does exist in the wild.
Comment: I'm not so sure. I had one professor who made the make-up exams literally impossible to pass (think "prove l'Hopital's rule" for the first exam in Calculus 101, before it's even been mentioned) because he thought that people were just using them to buy more time to study. It's possible the prof is just spectacularly bad at writing exams, but with such a huge disparity it's... odd, to say the least.
Comment: @R.T It's also worth noting that if the matter is not resolved to your satisfaction, most institutions have some sort of procedure for appealing an unfair grade to some higher authority.  You'll need to look up your institution's regulations to see how this works.  There's usually considerable deference given to the instructor's decision, but this case sounds like it could be sufficiently extreme to overcome that.
Comment: @R.T For closure here, consider coming back and appending an edit to your question telling us how this turned out. In particular, was this nice accepted answer right in your particular situation.
Comment: I have taken many exams and never felt that one was unreasonably difficult until now. I honestly feel that it was meant as a sort of punitive measure, and I am not the type of person who is quick to play the victim card.
Comment: So the TL:DR on your answer is to wait and see how the exam is marked before making a fuss.  Sounds reasonable; a followup question might be required if the grading isn't reasonable, but it's probably not a good idea to react in any way yet.
Answer: It's been a long time since I took a university course but I wonder if you might be unduly concerned about the makeup exam? From what I hear, professors are very prone to use Bell curves when marks aren't what they hoped for. For what it's worth, I once taught a database course at a college when a friend who had the gig normally had a conflict and couldn't do it. I wrote a pretty straight-forward exam with no trick questions or indeed anything terribly challenging but the marks were disappointing, mostly in the 60s and 70s. I'd already heard vague general rumours about colleges and universities belling up marks so I asked if I was supposed to be belling up the grades. The department head strongly encouraged me to do so. On reflection, I decided that the exam was perfectly fair and I could not justify altering the marks; I submitted exactly the grades the students had earned. I never heard further about it beyond one student expressing his disappointment that he hadn't gotten a mark of 90+ as he had with the other courses in the program.
If Bell curves are truly rampant in academia, then this may well solve your problem.
Comment: A bell curve would be ok for a class with a hundred students, but creating a meaningful bell curve when only a handful of students are taking the test is impossible.
Comment: @MaxW - Thanks for explaining that. I have only the most rudimentary knowledge of statistics. The department head at the college where I taught may have been in the same boat: the class I mentioned in my anecdote was only 6 students yet he apparently thought I could bell up the marks, as did the instructor I was substituting for, who has a stronger math background than I do.
Answer: Late, but I suspect the right answer is somewhere between the other answers.
As Buffy says, I think you should wait until the results come out before starting any sort of formal process. It could be that your grade will be better than you hope, and certainly it's hard to complain that your grade is unfairly low before you even have a grade.
On the other hand, as Daruiod's (edited) answer points out, I do think it is unlikely that your professor just accidentally made the exam way too hard. This probably was a strategic move. The suggestions about including other students in your complaint, and talking to the professor before grades come out, also make sense.
So, in summary, my recommendation is to:

Talk to the instructor (politely) before you get your grade, and say that you understand that the makeup exam is harder to prevent strategic sicknesses, but you have a well-documented illness and you hope that the grading will reflect your knowledge. The professor won't lose face if he gives you a good grade the first time, but his position will be a bit more entrenched after he returns your graded exam.
If despite this he still gives you an unfairly low grade, you will have no choice but to appeal. Don't talk to the professor again, but go to the department chair or whoever is in charge of grading procedures. Professors typically have wide latitude in such matters, but manifestly punishing you for an illness/disability just might be enough to win such an appeal.


Dusting Inside All-In-One computer

Question: I have an HP Pavillion 20 with everything inbuilt in the screen and I want to dust the hardware within the screen just like I used to take the side of my old tower and dust inside there.  I have no idea how to do it. Can anyone help
Comment: you have dust inside your screen? are we talking CRT?
Comment: No, I think she's talking about an all in one, and the system board inside it.
Comment: Someone please change "windows-8" tag to "cleaning" or something. I have no permissions on this community yet.
Answer: All-In-One systems such as the HP Pavilion 20 are much like laptops for cleaning, as they are designed to be difficult to take apart, and even attempting to do so can void your warranty. There are no user-friendly side-panels to take off, and removing the machine screws will mean HP will not support the machine for hardware failures.
You should still be able to clean it. HP recommends a small battery-powered vacuum to clean out the cooling vents, which are located on the back of the machine around the perimeter of the screen. As your HP Pavilion is so thin, this should be very successful, as long as there is not a significant buildup and are not in a damp, dusty environment.
Fans should be held steady to prevent damage to them. If the fans are close to the vents, you can hold them steady with a toothpick in one hand while you vacuum with the other.
A can of compressed air could also be used in combination with the vacuum to assist loosening material, but if you do not use it in combination with a small vacuum you run the risk of blowing the dust further inside the machine and clogging it even more.
Comment: +1 I like answers with references (link to HP recommendations).

Dusting Inside All-In-One computer


How to use Google Cloud CDN with the Google Blobstore Image Service and Google App Engine?

Question: I'm looking into using Google Blobstore with the Image Service, and possibly Google App Engine for a service I'm building. However, 12¢ per GB outgoing bandwidth is a little pricy. I noticed they have a CDN service with much cheaper bandwidth costs, but I haven't been able to figure how or even if it is possible to use the CDN service on top of the Blobstore and Image Service. Is anyone able to shed some light on this for me?
Answer: As per the documentation found here, the Cloud CDN content delivery network works with Google Compute Engine HTTP(S) load balancing and as stated here, replaces the network egress charges that apply when serving directly from a Compute Engine instance. Therefore, in order to benefit from this feature, you would need to create and manage a GCE instance with additional costs as detailed in this link. Moreover, the Images API is part of the App Engine Platform and would additionally require its own App Engine instance connected to your GCE instance.
A possible solution for your initial setup would be to use a Google App Engine instance with the Images API, but instead of Blobstore(As recommended by Google) with Cloud Storage buckets located closer to your users.
As an example, the setup would work as follows:

Via the App Engine application, modify an image directly from a Cloud Storage bucket with the Images API (More info can be found here).
In order to save costs, transfer the modified image to a Cloud Storage bucket located closer to your recipients (Pricing info about Network(Ingress) and regional data transfer can be found here).
Send to your recipients the public URL of the modified image from the Cloud Storage bucket so they can access it.

For more information about pricing you can either estimate the cost of your setup using the Google Cloud Platform Pricing Calculator or contact Sales using this form.


MySQL upgrading from 5.7 to 8 - Throwing strange error and won't start up

Question: I followed the instructions on the MySQL web site and got MySQL server 8 mostly installed but it won't launch because it fails pretty quickly during the upgrade process. The apt-get portion installed all the files. But when it launches this is what is added to my error.log file and I have no clue what to make of it and Google is not being helpful.
<code>2018-09-07T12:25:54.281373Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.12) starting as process 3662
mysqld: /export/home/pb2/build/sb_0-29394547-1530206990.8/release/mysql-8.0.12/sql/dd/upgrade/table.cc:1075: bool dd::upgrade_57::add_triggers_to_table(THD*, TABLE*, const String_type&, const String_type&): Assertion `t->get_event() >= t_type && (t->get_event() > t_type || t->get_action_time() >= t_time)' failed.
12:27:19 UTC - mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.

key_buffer_size=16777216
read_buffer_size=131072
max_used_connections=0
max_threads=300
thread_count=1
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 134902 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x55ae33b103a0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 7f082a824da0 thread_stack 0x30000
/usr/sbin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x3d) [0x55ae31bc258d]
/usr/sbin/mysqld(handle_fatal_signal+0x423) [0x55ae30dfcde3]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f083e593890]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f083c98fe97]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f083c991801]
/lib/x86_64-linux-gnu/libc.so.6(+0x3039a) [0x7f083c98139a]
/lib/x86_64-linux-gnu/libc.so.6(+0x30412) [0x7f083c981412]
/usr/sbin/mysqld(+0x1abc55b) [0x55ae31b8155b]
/usr/sbin/mysqld(dd::upgrade_57::migrate_all_frm_to_dd(THD*, char const*, bool)+0x562) [0x55ae31b82042]
/usr/sbin/mysqld(dd::upgrade_57::fill_dd_and_finalize(THD*)+0xf2) [0x55ae31b554f2]
/usr/sbin/mysqld(+0xde1e96) [0x55ae30ea6e96]
/usr/sbin/mysqld(+0x1f920af) [0x55ae320570af]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76db) [0x7f083e5886db]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f083ca7288f]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0): is an invalid pointer
Connection ID (thread ID): 2
Status: NOT_KILLED

The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2018-09-07T12:27:20.027024Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.12) starting as process 4161
</code>
I know this is all that is being added because I am adding a few blank lines to the log just before trying to launch MySQL and this code is all that comes up after my injected blank lines.
I am running Ubuntu 18lts server. MySQL 5.7 rand fine and my database had no errors because I checked it before trying the upgrade.
Answer: I suspect this may be caused by a bug that happens when in-line upgrades go from 5.5 to 5.6 to 5.7 then finally 8.0.
The suggestion to deal with this is to run optomize table on every single table while in version 5.7. Once the 8.0 upgrade is attmpted, it is too late because you cannot go back.
I am giving up, rebuilding this server from scratch, then install 5.7 and perform the optomize table then try the upgrade to 8.0 again.
Good thing I have another 5.7 server running and a full backup of all the data.


What are the odds of a mob in minecraft dropping all 4 peices of armor that it is wearing?

Question: I was playing Minecraft Bedrock with a sharpness 2 and unbreaking sword (so no looting) and killed a drowned wearing full gold armor, killed it, and it dropped all 4 pieces of armor and almost full durability. Can somebody tell me the odds of this happening?
Answer: There's a 5% chance that any armor will drop, and the only way to change that is to create a custom mob. Also, looting doesn't affect chances of a mob's armor dropping. Mob armor never drops with full durability, most likely it will be broken before it is dropped. And, rare drops occur 2.5% of the time. There are 6 possible rare drops from a zombie, 4 of which are armour, which I will assume have the same chance of happening. Therefore the percentage of zombies that will drop a piece of armour is 1.67%, or a chance of 0.0167.
Comment: I should probably add that in the context of armored zombies, there was a point in time where you could drown them in a body of water, and since drowns can't wear armor or hold the types of weapons that regular zombies can, the items would pop of the drown, so were guaranteed to drop whatever they were holding or wearing in their true durability (rather than the rng durability loss drop mechanic effecting the item's durability), being the most reliable way to get full durability armor and weapons from zombies. I'm not sure if this is still a feature anymore, but it's quite easy to test out.


Are there any atmospheric properties that might make iridescent clouds more common on a different planet?

Question: I'm designing a few planets and the life that could inhabit them, and was wondering if an uncommon Earth phenomenon like iridescent clouds might be more common on a planet under different conditions. Are there any atmospheric properties that would make iridescent clouds a more common occurrence? I think it might be cool to include this as a feature on one of my planets.
Answer: The key to having strong iridescence is the uniformity in the distribution of  the droplet or ice crystal size and that the they are relatively small. A strong light helps make the phenomenon more visible and the cloud can not be optically thick or you won't get a strong effect.  By relatively small, most cloud droplets are between 1 and 10 um but iridescent clouds the droplets are probably less than 1 um or around 1 um. If the particle size is changing you may see a shift in color.
So for your world a bright sun and perhaps strong upper atmospheric winds to shear the clouds so they don't get too thick.  The effects would be most strong when looking in directions near the sun.
To keep the droplets more uniform, I think not having as many vertical convection currents within the clouds might help to keep the particles small. Of course you have several different cloud types and you still may want to have thunderstorms.
Since the droplets in clouds often nucleate around a small particle which needs to be less than 1 um, it might be that you have some special way to introduce a special uniform particulate size. Maybe some kind of air-born microbe, or dust particle from some dessert where for some reason the dust is especially fine, or a volcano emitting something very fine.
Comment: Thanks!!  I have a couple more questions now if you still wanna help: what would cause fewer vertical convection currents within the cloud? And how do you think the thickness of the atmosphere/scale height and air density might affect the thickness of the clouds? If I had a lower g planet with a less dense atmosphere, would that create thinner clouds and enhance the effect or would the clouds being less dense make them more optically thick with the droplets being more spread out (I also guess I don't know what optically thick means exactly lol)?
Comment: Optically thick is just a fancy way to say that the light has to make it through the cloud for you to see it. So wispier, thinner clouds or the edges of thicker clouds are more likely to have the effect. I think temperature differences and availability of water moisture is more important than gravity, or  the density of the atmosphere, unless you really push it. This website https://www.weather.gov/source/zhu/ZHU_Training_Page/clouds/cloud_development/clouds.htm explains cloud formation  is pretty good.
Comment: Not sure about how to limit thunderstorms, except by limiting humidity, but even then water vapor gets pushed from humid areas to drier areas some times. I think you can think some about the geography and geology. Mountain ranges are wetter on the ocean side, and dryer on other side etc.  But really it is your story, if you want shimmering clouds on the top of a mountain range, or a certain time year the iridescent clouds are likely to appear I think you are o.k.


not included in my job description

Question: So I am kind of being lazy but im just trying to do exactly what I am supposed to. I was hired to do, and I quote, "mow the lawn, trim with a weed eater, and rake debrees".  I was asked by a manager, who is not my boss because I was hired directly by the company, to water the lawn.  I declined and have not been.  She told me that if she hired me that I would have been fired for not doing all lawn maintanence as in my description, but my contract is very short and says nothing more than my three tasks.  Should I just start watering or stick to my contract?
Comment: Does this manager have any authority to give you tasks?  And often you can be asked to do things that aren't necessarily exactly what is on your job description but can be assumed to be reasonably related.
Comment: How would lawn-watering affect your job? Is it a matter of working more hours? If lawn-watering had been included in the contract to begin with, would it have affected your willingness to take the job (or might you have asked for more pay or other benefits)?
Comment: The manager has no authority over me and my job description doesn't say to do all lawn maintenence it just says mow, weed eat, rake.  If it had said water I would have wanted paid more, but it doesn't, so should I do it anyways.
Comment: And if you do turn this down, even if you aren't fired, you can guarantee you won't be getting a good reference from this employer in the future.
Comment: Could you elaborate on the nature of your contract? Were you asked to just do those three tasks once and your job is over? Or is it you work there anyway and your time is to be spent doing those three tasks? If the latter than I agree with everyone else, because you're doing work for them anyway... Unless you don't feel properly trained to water lawns or something. If the former, then you would have a point as you're being asked to do *extra work*, having already completed the work you've agreed to do.
Comment: Firstly I have accepted an answer so I don't know why i'm getting more, but no my contract says to do just those things.  Probably because originally it was the regular employees job to figure out how to do lawn maintanence and they hired me because the employees said the physical labor was to hard.  But watering the lawn is not physically demanding and in their comtracts it says they have to do as asked by the company... mime doesn't.
Answer: You aren't being asked to do anything illegal or completely outside the bounds of the type of work you are doing so I would suggest that it's completely reasonable to tell you to do that as well.
For example, I'm a software developer.  My job description never mentioned anything about configuring database servers, but I do it because it's related to what I am doing, and it's something I can do.  The fact that it helps me do my job is a bonus but not necessarily a reason.
I would say that normally a job description is a guideline of the type of work you will be asked to do, not a finite set.
Comment: Amen!  My job description never mentioned  forcing myself daily to perform painfully mundane smalltalk or listen to country music in the office, but by God, I get it done!
Answer: Insisting on doing only a specific set of tasks is a good way to get fired and replaced with someone more flexible. Your job is what the boss says it is, within reason.
Answer: Ask yourself: What good are you to the company, if they hired you to look after the lawn, but they have to find someone else to water it? The company's choices are: Let the grass die. Ask someone else whose job responsibilities have nothing to do with the grass to do it (I'd be more than willing to water the grass all day long as long as my manager knows why I can't handle the tasks that I should handle). Hire someone.
Long term, they have to hire someone. And that person will probably have all your other responsibilities on his list too, and then your job is gone. It's alright to say "I'm paid for X hours, and I'm not working more". But saying "this is not in my job description, find someone else", that's a sure way to get fired quickly.
BTW. Most people have "any other tasks as required by the business" in their job description.

not included in my job description


Dual core i7-3540M 3.0 GHz vs Quad corei7-3632QM 2.2 GHz

Question: I intend to buy a laptop to study parallel computing with GPU and multicore CPU. I don't know which is the better one between a Dual core i7-3540M 3.0 GHz and a Quad core i7-3632QM 2.2 GHz. Both of 2 latops has a Nvidia GT 650 graphic card. As far as i know, in GPU computing there is just one core of CPU to be used. So may be the Dual Core with higher clock speed make sense with better performance computing ? Do anyone please give me any suggestion? I really appreciate any reply. Thank you.
Answer: Quad core means twice as many cores as dual. This means it is able to run more applications at once. The i7 3636QM also has a larger L3 Cache meaning more data can be stored for quick access. Therefore the quad core processor seems to be better for parallel computing; even though it has a lower clock speed.
When you have a single task that needs to be done right away, multiple cores can help you by breaking the task into smaller chunks, working on each chunk in parallel, and thus you'll get your work done quicker. In lower end tasks you would probably see a higher clock speed in a dual core work better; however in more complex tasks a quad core processor with a lower clock speed is still likely to perform better. With scientific and engineering tasks(presuming these are the tasks you are expecting to do) Quad would always triumph.
Comment: Yeah, studying parallel computing on a dual core machine is slightly limiting.
Comment: As far as i know, in GPU computing there is just one core of CPU to be used. So may be the Dual Core with higher clock speed make sense with better performance computing ?
Comment: Updated post to meet needs of second question.


How can I separate gameview from UI most efficiently in Unity?

Question: Let me provide an image to illustrate what I mean. It is from a game called Runescape.
Comment: I feel this question may have a few issues that render it *off-topic* for game dev. Asking for the most efficient is not as bad as asking for the *best*, but you still might find that the answer comes down to opinion (including opinion of what is easier, and what looks better). You *also* have the massive "what are you actually asking" problem. ***Runescape is an MMO***. It has a *very* unique UI that represents its *very* unique mechanics. To understand the most efficient way, we need to know what we are including in the UI; and that is an entirely different ballpark, all together.
Comment: In contrast, we could answer this directly with "use a canvas"; have you looked into UI with Unity, before?
Answer: Like most things in Unity, there are many ways to skin this cat depending on your game's needs and your preferred workflows.
So, to narrow things down, I'm going to focus on one specific issue: rendering efficiency.
In the example you've presented, the 3D game view occupies only about 2/3 of the frame's width or height, with the rest occupied by opaque UI. If we were to render the game across the whole window, then layer the UI on top, we'd end up covering over half those pixels - so we would waste a lot of our frame time (and battery, on mobile) rendering content the player will never see.
To fix this, we can set up our 3D camera so it renders into only the screen pixels we want. We can do this using the Rect property of a camera (called "Viewport Rect" in the inspector), which lets us specify the horizontal and vertical fractions of the viewport the camera should render into. That way we skip rendering to areas of the screen that will be covered over (and the camera's center of projection will automatically align with the middle of the viewport, as expected, rather than the center of the screen, making the viewport appear subtly skewed)
Then we can layer UI over the whole screen using a canvas set to screenspace overlay.
As examples, you can see this answer about multiple projections or this answer's animations, which were accomplished using this viewport trick to render each view to its own designated rectangle of the game window.
If you need to do something a bit fancier - say, having the game viewport in a window element that can float around your UI, or cropping the game view to an unusual shape, you can accomplish this by creating a RenderTexture of your desired resolution for your camera to render into (using its targetTexture property), and then referencing that RenderTexture in a UI RawImage component, to be able to manipulate or animate the rendered view similar to how you would with any other UI widget.
Answer: I would suggest to have two cameras :
The first one to render only the game view by modifying the rect of the camera : https://docs.unity3d.com/ScriptReference/Camera-rect.html
Set it to something like :
camera.rect = Rect (0, 0.2f, 0.8f, 0.8f);

Then, create an other camera used to render an overlay canvas, and make sure all your elements are outside the rect given above.


what does this error mean and how to solve it "message":"Products \"%1\" and \"%2\" have the same set of attribute values.","parameters"

Question: I did an upload and the simple skus were created, but the configurable sku shows this error and is not created. What does it mean and how can I fix it?
Comment: Explain in details what you are trying to achieve?
Answer: It looks like the simple products that are linked up with that configurable do not contain unique attribute values. So if you have two child simple products attached to the configurable and they are using attribute color, for example one will need to be Blue and the other Red. This error will show if you have both simples set to Blue.
Comment: Thank you very much, you were right, I had two identical attributes in the simple skus, I made the correction and it was processed correctly


Problem In Getting Rinkeby Test Ethers

Question: I tried to get rinkeby ethers from https://faucet.rinkeby.io/ by creating a tweet but the website shows "insufficient funds for gas * price + value" error. I also tried the website faucets.blockxlabs.com, it shows the transaction to be successful but I didn't receive any rinkeby ethers. I am a newbie in working with test networks, any help would be appreciated. Thank u!
Comment: @cjauvin Ultimately, it has to do with the fact that "test" money isn't going to be very useful for testing unless it acts like money to an extent and that means some form of limitation, which ironically means you won't be able to get it too easily.
Comment: Post your address and I'll send you some
Comment: @SamuelDare 0x35B84d6848D16415177c64D64504663b998A6ab4
Comment: I'm currently following an Ethereum course on Udemy, and I really struggle to obtain some test ethers (I tried Rinkeby and Ropsten faucets, to no avail). All the answers I find online about that problem are of type "give me your address I'll send you some". It would be interesting to have a more general solution, or at least an an answer as to why it seems so hard to obtain test ethers in that particular time period.
Comment: The issue is now gone, I had the same problem. Just received my 3ETH by trying again.
Comment: I use this faucet: https://rinkebyfaucet.com/
Has never failed me.
Answer: I think the issue is on their side, when there is too much demand. There is nothing you can do other than trying some other day.
Today, it worked for me, where the other week I had the same issue as you.
Answer: Testnet faucets tend to be really faulty.

faucet.rinkeby.io -> I also had issues recently, but tried again right now and Facebook worked, while Twitter didn't.

faucet.metamask.io -> never works during standard working hours and you will get the <code>{"error":"[ethjs-query] while formatting outputs from RPC</code> error. However, try to wake up early (<7:00am) or go to bed late (>2:00am) and it will probably work. You have a limit of 5 ETH per hour, but if you use a VPN and go changing IPs, you can get more...
Answer: Alchemy has a reliable faucet, you just need to create an account with them https://rinkebyfaucet.com/ It's never left me down
Answer: You can try using the Ropsten test network you can get as quick as eth into your account. But there is only a limit of 5eths request per 1hr.
Comment: Thanks for the answer! As the OP asked for help with Rinkeby, answers should either directly help OP with the faucet on Rinkeby, or provide conclusive arguments for using a different testnet.

Problem In Getting Rinkeby Test Ethers


Holding positions in industry while being a professor

Question: I have seen many professors also hold positions in industry, say Data Scientist at Uber or Machine Learning Manager at Google. How does this work? Do professors apply for these positions or do the companies reach out to them? Also, I know some of these professors take a break from being at the university and go work full time for a while before coming back, while others split their time between both. I am just curious if anyone knows/experienced how this process works.
Answer: Many possibilities:
Sabbaticals,
leaves of absence,
some Universities have "close" contacts with industry and some faculty have combined teaching / research roles...
Some engineering Universities really value faculty who have actually done real work and students appreciate that as well. Nothing like having someone talk about sensors and issues with sensors like getting temperature readings from a brake disc that is glowing red while spinning at 10K rpm... Compared to those "academics" that only ever push paper...
Some Universities even "use" final year engineering students to do funded research (their final year project) for particular issues using University machines as they have helped purchase said machines etc
Comment: Let me guess, downvoted by an academic paper pusher... without the courage to leave a comment...
Comment: OOPS, I guess I _did_ leave a comment. My bad.
Comment: Well, just upvoted by one, anyway.
Comment: Anyway, there are probably about as many variations as there are people. But note that some places make it hard/impossible to do this, again for a variety of reasons.
Comment: @Buffy Thanks, and yes, some places are better placed for industry links than others, we used to have courses that ran from 7pm to 9pm for workers to get there... Full time students did not like their pub time taken :)
Answer: Many professors work on 'project-basis' anyway
My experience is that many professors work on a 'project-basis' in any case. If you're a "research professor" then you often do some teaching, but that takes up the minority of your time. For everything else, you don't often have "hard employment" as in a full-time commitment to pay for arbitrary research, many universities don't really do that, but you have specific grants, specific projects that fund you (or some part-time of you - there often are multiple grant projects running at the same time) and a team to do some research.
In that context, there's little practical difference between a professor obtaining a grant that'll pay for half of their time for the next three years, a post-doc and two grad student research assistants, versus an industry contract that takes half of their time and allows them to lead a bunch of research assistants employed in that company (and some of them might defend a PhD thesis based on that work).


Decimal to ByteArray & write to offset

Question: I want to know how I would convert from a decimal number located in a text box to hexadecimal and then to a byte array and write this array to the offset I want, using BinaryWriter.
My textBox11 decimal value is "101200001" and I need to write the it's Hexadecimal value, which is "06 08 30 81", into a file at a speciffic offset.
This is the what I have, but I'm missing the conversion from textBox11.Text to byteArray.
    int index = listBox1.SelectedIndex;
    int startOffset = 0x00000008;
    int itemIDDiff = 0x00000328;

    BinaryWriter bw = new BinaryWriter(File.Open(_FileName, FileMode.Open));
    bw.BaseStream.Seek(startOffset + itemIDDiff * index, SeekOrigin.Begin);
    bw.Write( /* textBox11.Text converted to HEX then to byte array? */ );
    bw.Close();

This is part of the file that I need to write to:
00000330h: 02 00 00 00 00 00 00 00 4A 61 64 65 20 45 61 72 ; ........Jade Ear
00000340h: 72 69 6E 67 00 00 00 00 00 00 00 00 00 00 00 00 ; ring............

let's say I want to change the "02 00 00 00" to "06 08 30 81". How would I do this using the BinaryWriter?
Answer: You can't convert decimal to Hex (how would you deal with the fraction portion?). But you can use Int64 (a long) instead:
var text = "101200001";
var asLong = Convert.ToInt64(text);
var asHex = asDecimal.ToString("X");

asHex now has the hex string you're after.
But the problem you have is that 'hex' is really just a way of viewing a set of raw bytes on disk. And the way a number is represented in raw bytes depends on the program itself. If you've got a binary writer, you just need to know the byte representation of the number you're trying to write. This may be enough by itself (without converting to string):
bw.Write(asLong);

Looked at this more, and it seems as though you're after 4-byte numbers, so ints not longs. BitConverter is good, but it writes everything in reverse order to what you may want. So keep these in mind and review the below:
var text = "101200001";
var asInt = Convert.ToInt32(text);                    // 4 byte number
var asBytes = BitConverter.GetBytes(asInt).Reverse(); // same hex representation as a byte array (same order)

And so in your example add this:
bw.Write(asBytes);

Comment: This is part of the file that I need to write to:
00000330h: 02 00 00 00 00 00 00 00 4A 61 64 65 20 45 61 72 ; ........Jade Ear
00000340h: 72 69 6E 67 00 00 00 00 00 00 00 00 00 00 00 00 ; ring............

lets say I want to change the "02 00 00 00" to "06 08 30 81", how would I do that?
Answer: It isn't clear if little or big endian is required.  Little endian is simple:
bw.Write(int.Parse(textBox11.Text));

For big endian as suggested in the question but unusual, you have to reverse the byte order:
var bytes = BitConverter.GetBytes(int.Parse(textBox11.Text));
Array.Reverse(bytes);
bw.Write(bytes);

Answer: You could convert the number into hexadecimal representation, then parse that, but that would be totally pointless.
You use the Int32.Parse method to parse the string into a number, then the BitConverter.GetBytes method to get the number as a byte array:
byte[] data = BitConverter.GetBytes(Int32.Parse(textBox11.Text));

Then you write the bytes to the stream:
bw.Write(data, 0, data.Length);

Note that this will write the bytes 81, 30, 08 06 to the stream on a system with little endian number representation, e.g. an Intel (or compatible) CPU based computer. If you want the big endian representation in the file, you would have to reverse the array before writing it:
Array.Reverse(data);

Decimal to ByteArray & write to offset


Why is the Penrose triangle "impossible"?

Question: I remember seeing this shape as a kid in school and at that time it was pretty obvious to me that it was "impossible". Now I looked at it again and I can't see why it is impossible anymore.. Why can't an object like the one represented in the following picture be a subset of $\mathbb{R}^3$?
Comment: I'm not sure why this got a downvote. I think it's a great question for this site: while its impossibility may be obvious, clearly articulating why it's impossible is a bit trickier. Moreover, this question leads naturally into the broader problem of developing a *theory of* impossible figures, which has been pursued to a certain extent (see e.g. [here](https://math.stackexchange.com/questions/51525/geometry-or-topology-behind-the-impossible-staircase)).
Comment: It's not hard to produce 3-dimensional objects that match this picture when seen from a particular viewpoint: e.g. [this sculpture](https://en.wikipedia.org/wiki/Penrose_triangle#/media/File:Perth_Impossible_Triangle.jpg).
Comment: Another interesting point is that while it is definitely impossible to embed this thing in $\mathbb{R}^3$ (or even any $\mathbb{R}^n$ I think) _and have it look that way_, it is a perfectly sensible manifold "intrinsically". The implied surface forms a continuous loop so that traversing it indefinitely in one or the other natural direction you travel all over the entire figure.
Comment: I seem to remember some reasonably famous short article that uses sheaf cohomology to talk about this exact problem...
Comment: Same here! Actually now I think it is possible to make it (you just need to paint the sides in black, white and grey and not rely on a light source)
Comment: @The_Sympathizer According https://math.stackexchange.com/a/3636859/736690 every manifold is embeddable on $\mathbb{R}^n$ for large enough $n$.
Comment: @Carla Cvekla: Hence, my emphasis on "_and have it look that way_".
Comment: I believe it can be embedded at least in $\mathbb{R}^4$, but it will have a "twist". Hence, the "impossibility" is not intrinsic to the object topologically, but rather has something to do with the embedding space.
Comment: It is more correct to call it the Reutersvärd triangle https://scipython.com/blog/the-reutersv%C3%A4rd-triangle/ Reutersvärd was a couple of decades before Penrose.
Comment: Because it is nothing more than the illusion which is all it was ever meant to be… a trick designed to show us in general that looks can be deceptive and in particular, Nathaniel's point.

Because two dimensions can't in fact represent three much more than a flat map can represent the world sphere, even with Mercator projection.
Comment: @The_Sympathizer This is a good animation of that: https://www.pinterest.de/pin/329959110179677966/
Comment: @CarlaCvekla And isn't the implied manifold simply a torus?
Comment: @RobertIsrael "And from another angle, the sculpture resembled a goal post, leading the visiting team to accidentally attempt a field goal there twice, with amusing results."
Comment: @The_Sympathizer Actually I just thought some more and realize it is embeddable _topologically_ in $\mathbb{R}^3$. It's a series of gluings, you can do it there, it'll just be warped to make the connections. What you can't do is embed it so that all edges are geodesics under the usual metric and standing at right angles to each other. To make it work you need a nontrivial point in the space around which some interesting things happen. Mathematically, you take the realistic sculpture and quotient the hanging edges. You can do that in real life, too, but you'll bend some of the bars.
Comment: So yeah, it has a twist as I said, just thought one dimension more than you actually need.
Comment: @Tim : yes, by Penrose himself "ON  THE  COHOMOLOGY  OF  IMPOSSIBLE  FIGURES".
Answer: I can't resist posting an answer based on the Mathematics Stack Exchange logo.

Let's add some more cubes to the logo to make it clear that it's a subset of the Penrose triangle (or would be, if it was a real 3D object)

Now note that the cubes are overlapping, so some must be in front of others. But in fact, each cube is partially obscured by at least one other cube, in such a way that it appears to be some distance behind it. You can go around the hexagon in the original logo, in clockwise order, and see that each cube appears to be located further from the 'camera' than the next one in the cycle - which means that each cube is in front of itself. There's no consistent "z ordering" that you can give to the different parts of the figure, and that's one way to see that it's impossible.

In reply to some of the comments, just to be explicit, the point here isn't just that the cubes all overlap each other. If that was the case it would be incorrect, since it's possible to have mutually overlapping arragements of cubes, as in this image provided by Misha Lavrov.

However, if we're assuming that the Stack Exchange logo is a subset of the Penrose triangle then we know the cubes aren't arranged like that. Instead, each cube is positioned so that some of its sides are coplanar with those of the next cube, and each cube is separated from the next by some distance in the z direction, where z is perpendicular to the plane of the image. Therefore the cubes' centres of mass can't be given consistent z coordinates.
As an extra bonus point, even if we don't assume that, and instead assume that each cube is as close to the next as it can be (in the z direction) without the surfaces intersecting, the Math.SE logo still can't be made into a consistent 3D shape, as the following animation shows. Note that it doesn't quite form the Math.SE logo, since one cube ends up in front of all the rest. Of the six neighbouring pairs of cubes, three of them can have equal z coordinates, but for the remaining three pairs, one cube unavoidably has to have a greater z coordinate than the next.

As another additional bonus point, although it's not possible to embed the Penrose triangle into normal, flat, Euclidean 3D space, it is possible to embed it into curved three dimensional space. The video below, by @ZenoRogue on Twitter, shows Penrose triangles embedded into something called "nil geometry". I don't pretend to understand the details, but it's a kind of curved space such that Penrose triangles really are possible.
video link: https://www.youtube.com/watch?v=YmFDd49WsrY
screenshot:
Comment: I feel like this is missing something since it's possible to have a set of 3d objects where each one is in front of and behind another. For example, when folding the sides of a cardboard box to close it: https://assets-global.website-files.com/5e136d26c5e98c478100e1c7/5e7504bffdfde87684302b74_no-tape-moving-box.jpeg.
Comment: Thanks, reading this answer made it intuitively "obvious" again to me.
Comment: Here is a "possible triangle" with three cubes: https://i.stack.imgur.com/cSCg0.png Yet I feel like the same argument as in this answer (each cube is partially obscured by another) could be made for it, so this answer proves too much...
Comment: But ... you can have three cubes, where $A$ is in front of $B$ is in front of $C$ is in front of A, in the sense that $A$ partially obscures cube $B$ when you're looking at it.. With the cubes in the same orientation as your picture, put cube A with its bottom front corner in the center of the top face cube B, and put cube C so that its top left corner is in the middle of the right face of cube A.
Comment: Another interpretation of this image would be, if you label sides of the cube as X, Y, Z corresponding to the axes: you move 3 steps on the X axis, 3 on the Y axis, and 3 on the Z axis, which doesn't leave you back where you started. At least that's why this image looks suspicious to me. (Of course, this is then just a really good illustration of the answer by John Bentin)
Comment: @mowwwalker sure, but if you look at how the cubes are drawn, they appear not just to partially occlude each other, but to be actually located some distance behind each other in space. As in, if the figures actually represented real cubes in the way they appear to, their centres of mass would be at substantially different distances from the 'camera'.
Comment: @PeterShor after your comment I had to check, and it turns out that it's not possible to make the math.SE logo as a real 3D object using that trick. (Too bad - I'd have made a 3D printed one otherwise.) Here's an animation to show what I mean: https://gifyu.com/image/QTQd
Comment: There is probably a way to make this rigorous, but it's not satisfactory to me as stated. The comments have already pointed out why the argument falls short.
Comment: @MishaLavrov did you view the animation in my previous comment? I made it specifically to address that issue, which was raised previously by Peter Shor.
Comment: Okay, but just because *one* way to do it doesn't work, doesn't mean that there is *no* way that works.
Comment: @MishaLavrov in my animation, the cubes are as close to each other (in the z direction) as they can be without intersecting each other. So in this particular case, the fact that that way doesn't work *does* imply that no other way will work.
Answer: Start at the bottom left-hand corner, taking othonormal unit vectors $\pmb i$ horizontally, $\pmb j$ inward along the cross-member bottom left-hand edge, and $\pmb k$ upward and perpendicular to $\pmb i$ and $\pmb j$. I'll take the long edge of a member as $5$ times its (unit) width; the exact number doesn't matter. Then, working  by vector addition anticlockwise round the visible outer edge to get back to the starting point, we have $$5\pmb i+\pmb k+5\pmb j-\pmb i-5\pmb k-\pmb j=4\pmb i+4\pmb j-4\pmb k=\pmb0,$$which of course is impossible.
Comment: Note also the ["real-world" versions](https://en.wikipedia.org/wiki/Penrose_triangle#/media/File:Perth_Impossible_Triangle.jpg) of this object are designed so that the total vector displacement (such as $4 \hat{\imath} + 4 \hat{\jmath} - 4 \hat{k}$ in your example) is along the line of sight, and so is visually perceived as the zero vector.
Comment: Great rigorous solution!
Comment: I agree with the comments that "along the cross-member bottom left-hand edge" is very unclear. Took me a full minute to decipher. You could edit to (1) first explain what you mean by a member, or alternatively just draw a picture.
Comment: I don't see where you get the $+\mathbf{k}$, $-\mathbf{i}$, $-\mathbf{j}$ terms from to begin with. I would make this whole argument simpler: the three blocks are orthogonal and of equal length; call them $\mathbf{i}$, $\mathbf{j}$, $\mathbf{k}$; then the closed-loop displacement is $\mathbf{i} + \mathbf{j} + \mathbf{k}$, which is clearly non-zero, i.e., impossible.
Comment: @Noldorin : The terms you cite correspond respectively to the bottom right, top, and bottom left (short) edges in the OP's diagram. I'm not sure quite what a "block" is, or how such blocks could be added. However, if we consider the three corner cubes, each common to two members (like the cubes added in Nathaniel's answer), then the three (mutually orthogonal) vectors between the cubes' centroids perhaps could represent each block, and they would sum to zero. While I agree that three vectors are simpler than six, I preferred to use easily defined vectors along the visible edges.
Comment: @JohnBentin Ah, I understand what you mean now. "along the cross-member bottom left-hand edge" had me slightly bewildered — in particular, I didn't know what you meant by "cross-member". (Maybe you could clarify for others reading, but up to you.) That said, I think your approach is a good one, since those vectors are easier to define and envisage, as you say. I probably should have written "beam" instead of "block" above (one of three), but the fact these are 3D beams and not 1D edges makes an approach like yours better, so I take back what I wrote!
Comment: (My $\mathbf{i}, \mathbf{j}, \mathbf{k}$ vectors would have to cut through the beams, which is indeed awkward.)
Comment: I'm really having trouble following this :( What is the cross-member bottom lefthand edge? Or is there a way you could create a graphic to accompany this?
Comment: Would be great to have a diagram.
Answer:
Assume the white part is facing upwards. This is without loss of generality, since it just represents a specific rotation of the whole thing, which can't affect whether a shape is possible or impossible.
Now we know both the right and bottom columns (in the image) are on the same vertical plane / level (since they share the white horizontal surface).
Based on the connection between the left and right columns, we also know the left column extends downwards from the above plane (since it's on the opposite side of a side that's facing upwards).
This implies at least part of the bottom column is below the right column.
But we've already established they're on the same vertical plane, so we have a contradiction.
Thus this shape can't exist in 3D.

This is of course based on the assumption that each part of the image filled with a single solid colour represents a flat (uncurved) continuous surface and adjacent surfaces are connected at the same points as in the image and they point in different directions.
Comment: +1 for pointing out the underlying assumption. Without this assumption, I'm pretty sure you could produce a connected solid shape that was topologically equivalent to the Penrose triangle - though the geometric shape would be different.
Comment: @RobinSaunders A torus is topologically equivalent to the Penrose triangle. :-) (The 'twist' in the shape comes out in the wash...)
Comment: Yes, that's true. I guess I meant "smoothly equivalent".
Comment: Yes, making the assumptions explicit is important. Otherwise this would be a solution: https://youtu.be/CVOU8OTcgOQ
Answer: It's helpful - as is often the case - to boil the picture down to something simpler. In this case, let's just think about three particular polygons sitting in $3$-space: the (visible) black, white, and grey $L$-shapes. These are themselves contained in three planes, which I'll call $P_b, P_w, P_g$ respectively.
Now let's think about how these planes intersect - say, $P_b$ and $P_w$. We have one visible intersection, namely the "front" edge of the bottom cylinder where the black and white shapes themselves meet. However, we also have another intersection: if we "continue" the top of the black $L$, it will eventually meet the white $L$ at its top. So in fact $P_b$ and $P_w$  intersect in two distinct lines, and in particular they have at least non-collinear three points of intersection. But two planes which intersect at three non-collinear points must be the same plane - and that can't be the case here, since the black and white shapes clearly meet at right angles.
Comment: Put another way, the *question itself* isn't fully rigorous as written since it doesn't actually say what a Penrose tile is precisely. A rigorous version of the question would be e.g. "Why can't we have in $\mathbb{R}^3$ a set of three square-based prisms such that [intersection conditions]?" The process of teasing out the "implied conditions" is necessary to answer the question; for me, I read the picture as implicitly declaring that the various "faces" are in fact flat and do in fact meet at right angles as suggested.
Comment: I can't quite say how, but I feel like this is relevant: https://commons.wikimedia.org/wiki/File:Perth_Impossible_Triangle.jpg
Comment: Hmm. What about perspective? This doesn't seem very rigorous.
Comment: @Burnsba The "right-facing" plane is no longer a plane, but actually two planes whose normals point in different directions.
Comment: @user118161 I am not sure what you mean. Any analysis of the figure in question has to further interpret it, since certainly we **can** in reality produce objects which look like the figure in question *(see Bumsba's comment)*. Any answer has to translate the drawing into some precise description of a mathematical configuration - either in terms of a family of vectors satisfying some algebraic relationship, or in terms of some family of planes satisfying some geometric relationship, or whatever. I have written colloquially, but this is ultimately no less rigorous than any of the other answers.
Comment: (In my previous comment, "Penrose tile" should of course be "Penrose *triangle.*)
Answer: This is only impossible because we try so hard to see three dimensionality in the figure.
As I read through the answers and stared at the figure, it ceased to be 3 dimensional, and instead became Three identical asymmetrical V-shapes lying flat on a plane.  Easily describable, easily drawable, and completely flat.
Our experience has trained our optical neural nets to see three dimensionality, and it generally serves us well.  In this case, the local fit with three dimensional corner shading bumps into our higher-level matching against known figures, and the tension is born.  Clearly this is a trivially possible figure -- it appears several times in the question and answers.  It is our perception and expectations that are wrong.
Answer: Imagine keeping the corners in the same place, but reducing the width of the square cross-section of each side down to zero, until each side is a one-dimensional line segment. You would end up with a triangle with three $90^{\circ}$ angles, which is impossible in Euclidean space $\mathbb{R}^n$.