Why can't sudo redirect stdout to /etc/file, but sudo 'nano' or 'cp' can? Why does redirection, using sudo give me an error for the following commands?   $ sudo printf "foo" &gt;/etc/file bash: /etc/file: Permission denied  $ sudo printf "foo" ~/file; cat ~file &gt;/etc/file  bash: /etc/file: Permission denied   ...yet I have no such problem when I use an editor, or cp. I don't think I've ever tried this before, so I don't know if there is something haywire on my system, or if this is normal. It seems a bit restrictive to be normal, but(?) maybe it is intended to be restrictive...  (using Ubuntu)
Redirecting stdout to a file you don't have write permission on When you attempt to modify a file without having write permissions on it, you get an error:  &gt; touch /tmp/foo &amp;&amp; sudo chown root /tmp/foo &gt; echo test &gt; /tmp/foo zsh: permission denied: /tmp/foo   Sudoing doesn't help, because it runs the command as root, but the shell handles redirecting stdout and opens the file as you anyway:  &gt; sudo echo test &gt; /tmp/foo zsh: permission denied: /tmp/foo   Is there an easy way to redirect stdout to a file you don't have permission to write to, besides opening a shell as root and manipulating the file that way?  &gt; sudo su # echo test &gt; /tmp/foo
How do I fix the GPG error "NO_PUBKEY"? 90s (or earlier) movie with experimental, invisible, teleporting, time-traveling ship "Thanks for having me" Recently, I finished my phone job interview with the phrase "Thanks for having me". It was a reply to the other person's "Thank you for your time". So, does "thanks for having me" sound alright in this context? Variational Derivation of Schrodinger Equation Example of $\deg(fg)<\deg(f)+\deg(g)$ Let $R$ be an integral domain and $f,g\in R[X_1,...,X_n]$ where $n&gt;1$. What is an example of a pair $f,g$ such that $\deg(fg)&lt;\deg(f)+\deg(g)$?   Moreover, I have proven that the units of $R[X_1,...,X_n]$ are just the units in $R$. (Proof is done inductively) Is it true?  EDIT    Even though the each term in the underlined summation is nonzero, isn't it possible that the summation is 0? Why is this impossible ? How to avoid using sudo when working in /var/www? I want to stop having to use sudo everytime I work in /var/www. How can I do that? I simply want to put all of my sites into this directory and work with them without too much pain. lualatex MWE not working Can I get an enters-the-battlefield effect out of a second legendary before I must sacrifice it? If I have a legendary creature out, and I make a copy of it (such as by enchanting it with  or making a ), do I get enters-the-battlefield effects from the creature before I have to sacrifice it to the legend rule? Coupon collector problem with partial collection of a specific set of coupons I am very new in probability and combinatorics and have a naive question around a variation on the coupon collector problem with partial collection.   Lets assume we have a box with 45 coupons labeled 1-45. Now in this case I would like to adjust the CCP such that I can calculate the expected value (amount of draws necessary) to collect 10 specific items. For example item 1-10. How do I adjust my model such that I can calculate the amount of draws necessary to collect each item n times.   I assume that I have to adjust CCP2 in following post () to include the probability that I catch one item is 10/45.   All tips and tricks are welcome!  Thanks for your help Object created by joining several objects doesn't rotate uniformly consistently Aloha.  I'm experiencing a similar problem I had with a prior posting  with another object I created by joining 3 objects that doesn't rotate uniformly consistently.  I tried clearing and applying rotation of individual objects and joined objects to no avail.  I have  as well as object by itself in blend file if you need to see them  Any ideas?  Thanks. Most efficient way to check for DBNull and then assign to a variable? This question comes up occasionally, but I haven't seen a satisfactory answer.  A typical pattern is (row is a DataRow):   if (row["value"] != DBNull.Value)  {       someObject.Member = row["value"];  }   My first question is which is more efficient (I've flipped the condition):    row["value"] == DBNull.Value; // Or   row["value"] is DBNull; // Or   row["value"].GetType() == typeof(DBNull) // Or... any suggestions?    indicates that .GetType() should be faster, but maybe the compiler knows a few tricks I don't?  Second question, is it worth caching the value of row["value"] or does the compiler optimize the indexer away anyway?  For example:    object valueHolder;   if (DBNull.Value == (valueHolder = row["value"])) {}   Notes:   row["value"] exists. I don't know the column index of the column (hence the column name lookup). I'm asking specifically about checking for DBNull and then assignment (not about premature optimization, etc.).   I benchmarked a few scenarios (time in seconds, 10,000,000 trials):  row["value"] == DBNull.Value: 00:00:01.5478995 row["value"] is DBNull: 00:00:01.6306578 row["value"].GetType() == typeof(DBNull): 00:00:02.0138757   Object.ReferenceEquals has the same performance as "=="  The most interesting result? If you mismatch the name of the column by case (for example, "Value" instead of "value", it takes roughly ten times longer (for a string):  row["Value"] == DBNull.Value: 00:00:12.2792374   The moral of the story seems to be that if you can't look up a column by its index, then ensure that the column name you feed to the indexer matches the DataColumn's name exactly.  Caching the value also appears to be nearly twice as fast:  No Caching: 00:00:03.0996622 With Caching: 00:00:01.5659920   So the most efficient method seems to be:   object temp;  string variable;  if (DBNull.Value != (temp = row["value"]))  {       variable = temp.ToString();  } Is there a way to check if a file is checked out by another user? I am going trhough a list file by file and would like to avoid the "file is opened by another user" error. Something like this would be nice:  Guid id = new Guid(slideLibrary); // ID of Slide-Library. List list = ctx.Web.Lists.GetById(id); ListItemCollection items = list.GetItems(CamlQuery.CreateAllItemsQuery()); ctx.Load(items); // Loading all the fields System.Security.SecureString pwd = new System.Security.SecureString(); foreach (char c in "pwd".ToCharArray()) pwd.AppendChar(c);  ctx.Credentials = new SharePointOnlineCredentials(login, pwd); ctx.ExecuteQuery();  // Iterating through all the entries. foreach (var item in items) {     String currentID = item["ID"].ToString(); // Getting the ID of the current item.      if (!item.IsCheckedOut()) // This is the part I am looking for.     {        // Do stuff     }     else     {        Console.WriteLine("Item is blocked, skipping it.")     } }   I have yet not been able to find something fitting. Transferring a Windows 8 license and proper un- and reinstallation Long story short  I have two computers: a laptop and a desktop computer. Both have Windows 7 on them.  I buy the Windows 8 Pro upgrade. To see if it screws up anything, I install it on my laptop as a guinea pig. I intend to use Windows 8 for my main computer, my desktop, but I want to test it on the laptop, so I know I don’t risk losing access to my desktop and the data on it. I never use my laptop, and only used it, because it already has a Windows 7 installation on it.  The problem  At some point, I must have entered the license key on my laptop, because when I go to the activation screen on my desktop, I get this:    Uh-oh. I can’t use the key on my desktop. Now how the hell do I transfer the key from my laptop to my desktop computer?  Answers and suggestions so far  Let’s just say that I tried everything possible to get some answers on this matter. The best response I got from Microsoft is this:     To install Windows 8 on your desktop, do the following:         Uninstall Windows 8 on your laptop   Afterwards, install Windows 8 on your desktop   If it won’t activate, call product activation at (...)      I am not a fan of that last point. The error message does allude to such a solution, however:     If you’ve reinstalled Windows or made changes to your hardware recently, you may be able to use your current key.   The question  My main question is this: has anyone been in a similar situation, and if so, what did you do to resolve this?  Failing that, what is the proper way to   uninstall the Windows 8 installation on my laptop, and reinstall the Windows 8 installation on my desktop?   Ad 1  I have already tried using the “reset” feature on my laptop, but that only resulted in a new Windows 8 installation that was already activated. But which is the right way to uninstall the installation in a way that allows me to use the license key on the desktop computer?  Ad 2  Which is the proper way to reinstall the Windows 8 installation on my desktop computer? Why do I even have to reinstall it in the first place?  I won’t get around to do this, until my USB key with 3.0 support arrives in the mail, but it is going to be a while, until I find a assuaging response to the best way to go about this anyway. Show that if $a \neq b$ and a and b are positive then $\frac{a}{b}+\frac{b}{a}$ is never an integer In Windows 7, I know you can do Windows + Left to put a window in the left half of the screen.  Is there a feature that will do top and bottom? How to disable Spotify indicator in the top panel? The Spotify indicator icon clashes with the native Unity theme, and is redundant, since it is already listed in the Sound indicator menu. Is there a way to remove or disable the Spotify indicator? Or at least to change the icon (couldn't grep it on my filesystem). I am using the Spotify "preview" with 12.04. Thanks! Suppose that $A, B, C$, and $D$ are sets with the cardinalities related as  $|A|=|C|$ and $|B|=|D|$. Prove that the cardinality of $A\times B$ is equal to the cardinality of $D\times C$.  I know that I must prove the bijection of the function $f: A \times B \to C \times D$, but I am not sure how to say this? Can anyone help me? This morning I upgraded my system to Windows 10 2004, the upgrade went smooth and was through Windows Update. I am using Hyper-V as my virtualization program for virtual machines and to provide extra layer of protection to the system through core isolation. After the upgrade, I noticed that a new Virtual Switch was created with the name &quot;vEthernet (Ethernet)&quot; where &quot;Ethernet&quot; within the parentheses is the name of my primary network adapter. Also noticed this behavior has a specific pattern of creating new vSwitches correspond to the adapters you have, e.g. if you created a new Virtual Switch and restarted the system, a new additional switch will appear with the name &quot;vEthernet (your-new-switch-name)&quot;. Tried to remove Hyper-V and reinstall it but no luck. I am aware of a similar  on SuperUser but has no answers on it. Any clues for the root of the problem? I am playing a bit around with Qgis 2.14.6 to understand how it deals with distance measurement.  I took a line-shapefile that I saved in 3 different coordinate systems (4326, 32642 and a national one that doesn't exist in Qgis yet).  Using 32642 and the national one, the length is quite similar (6442m vs. 6428m)  But using 4326 (unprojected WGS84), I get 8057m  In all cases, I just used the Field Calculator and introduced $length.  I was already positively surprised that the result using 4326 was in meters and not in degrees.  To calculate the distance on the dataset in 4326, I assume that Qgis does some kind of re-projection in the background. Does anyone know which one?   Shapefiles here if anyone wants to play around:   EDIT - adding more info after more tests  As you can see, now both my shapefile and the project are in EPSG:4326, so unprojected:    Here the rough measurement of my shapefile, with the Qgis measure tool:   When I use the field calculator, the preview gives me a value in degrees, while the result seems to be in meters:      This would mean that the function $length, like the measurement tool, always gives a result in meters, but using a very coarse approximation of the degrees => meters transformation:    Is this a bug? or should it really behave like this? I find it at best counter-intuitive (but maybe it's just me) and, at worse, completely misleading (it makes very little sense to use, everywhere on earth, the length of 1 degree at the Equator). Any input or opinion here? Should I open a bug report (at least for the inconsistency between the preview and the actual result)? Derivation of $E=pc$ for a massless particle? In classical mechanics, massless particles don't exist because for $m=0$, $p=0$.  The relativistic relation between energy, mass and spatial momentum is: $E^2= (pc)^2 + (mc^2)^2$ . So it is said that setting $m=0$ in the first equation you get $E=pc$.  How could setting $m=0$ in that equation give you $E=pc$ whilst $p$ appears in the equation and we know $p=γmu$? If you set $m=0$ you will have indeterminacy due to "$γm$". It seems to me like we are doing a "trick" in order to get the $E=pc$. Perhaps there is another proof for this relation?