I am trying to center vertically and horizontally an image with variable width and height, maxing at 1000px. I archived vertical center but I am unable to add horizontal center without breaking vertical... Here is my code:  &lt;div style="margin-left:auto;margin-right:auto;width:70%;height:1000px;width:1000px;"&gt;     &lt;div style="display:table-cell;vertical-align:middle;height:1000px;width:1000px;"&gt;         &lt;img src="images/a.png"&gt;     &lt;/div&gt; &lt;/div&gt;
Best way to center a &lt;div&gt; element on a page both vertically and horizontally?  I know that margin-left: auto; margin-right: auto; will center on the horizontal, but what is the best way to do it vertically, too?
Redefining nodata value into zero in QGIS I have an image which I clipped with an AOI polygon. The contour area was set to pixel value = 0 and I have a nodata value of -32768. I want to redefine the nodata value into zero. I used to do this with ArcMap easily in the raster calculator, but in QGIS I don't see how I could do it. Any ideas? What is the maximum number of pucture repairs an inner tube can take? Handling large numbers in C++? I'm having some trouble understanding the purpose of a salt to a password.  It's my understanding that the primary use is to hamper a rainbow table attack.  However, the methods I've seen to implement this don't seem to really make the problem harder.  I've seen many tutorials suggesting that the salt be used as the following:  $hash =  md5($salt.$password)   The reasoning being that the hash now maps not to the original password, but a combination of the password and the salt.  But say $salt=foo and $password=bar and $hash=3858f62230ac3c915f300c664312c63f.  Now somebody with a rainbow table could reverse the hash and come up with the input "foobar".  They could then try all combinations of passwords (f, fo, foo, ... oobar, obar, bar, ar, ar).  It might take a few more milliseconds to get the password, but not much else.  The other use I've seen is on my linux system.  In the /etc/shadow the hashed passwords are actually stored with the salt.  For example, a salt of "foo" and password of "bar" would hash to this: $1$foo$te5SBM.7C25fFDu6bIRbX1.  If a hacker somehow were able to get his hands on this file, I don't see what purpose the salt serves, since the reverse hash of te5SBM.7C25fFDu6bIRbX is known to contain "foo".  Thanks for any light anybody can shed on this.  EDIT:  Thanks for the help.  To summarize what I understand, the salt makes the hashed password more complex, thus making it much less likely to exist in a precomputed rainbow table.  What I misunderstood before was that I was assuming a rainbow table existed for ALL hashes. We are provided with a string A (may contain repeated characters as well ). One needs to make all possible permutations of A , and find out how many pairs of strings chosen from these permutations are not similar.  Two strings are similar if we can make both of them exactly same by carrying out at most 1 swap in each of them .  Example :- if we are provided with string abcd  , then for permutation abcd , the permutations which are not similar to it are bcda , bdac , cadb , cdba , dabc , dcab . Similar is the case for other permuations as well. So overall number of desired pairs are 24*6=144 .  I tried solving it for each possible pair by approach mentioned here     But as the permutations can be large enough , I need a better approach of solving this. Ball to Ball Collision - Detection and Handling With the help of the Stack Overflow community I've written a pretty basic-but fun physics simulator.    You click and drag the mouse to launch a ball.  It will bounce around and eventually stop on the "floor".  My next big feature I want to add in is ball to ball collision.  The ball's movement is broken up into a x and y speed vector.  I have gravity (small reduction of the y vector each step), I have friction (small reduction of both vectors each collision with a wall). The balls honestly move around in a surprisingly realistic way.  I guess my question has two parts:   What is the best method to detect ball to ball collision? Do I just have an O(n^2) loop that iterates over each ball and checks every other ball to see if it's radius overlaps? What equations do I use to handle the ball to ball collisions? Physics 101 How does it effect the two balls speed x/y vectors?  What is the resulting direction the two balls head off in?  How do I apply this to each ball?     Handling the collision detection of the "walls" and the resulting vector changes were easy but I see more complications with ball-ball collisions.  With walls I simply had to take the negative of the appropriate x or y vector and off it would go in the correct direction.  With balls I don't think it is that way.  Some quick clarifications: for simplicity I'm ok with a perfectly elastic collision for now, also all my balls have the same mass right now, but I might change that in the future.    Edit: Resources I have found useful  2d Ball physics with vectors:  2d Ball collision detection example:     Success!  I have the ball collision detection and response working great!  Relevant code:  Collision Detection:  for (int i = 0; i &lt; ballCount; i++)   {       for (int j = i + 1; j &lt; ballCount; j++)       {           if (balls[i].colliding(balls[j]))           {             balls[i].resolveCollision(balls[j]);         }     } }   This will check for collisions between every ball but skip redundant checks (if you have to check if ball 1 collides with ball 2 then you don't need to check if ball 2 collides with ball 1.  Also, it skips checking for collisions with itself).  Then, in my ball class I have my colliding() and resolveCollision() methods:  public boolean colliding(Ball ball) {     float xd = position.getX() - ball.position.getX();     float yd = position.getY() - ball.position.getY();      float sumRadius = getRadius() + ball.getRadius();     float sqrRadius = sumRadius * sumRadius;      float distSqr = (xd * xd) + (yd * yd);      if (distSqr &lt;= sqrRadius)     {         return true;     }      return false; }  public void resolveCollision(Ball ball) {     // get the mtd     Vector2d delta = (position.subtract(ball.position));     float d = delta.getLength();     // minimum translation distance to push balls apart after intersecting     Vector2d mtd = delta.multiply(((getRadius() + ball.getRadius())-d)/d);        // resolve intersection --     // inverse mass quantities     float im1 = 1 / getMass();      float im2 = 1 / ball.getMass();      // push-pull them apart based off their mass     position = position.add(mtd.multiply(im1 / (im1 + im2)));     ball.position = ball.position.subtract(mtd.multiply(im2 / (im1 + im2)));      // impact speed     Vector2d v = (this.velocity.subtract(ball.velocity));     float vn = v.dot(mtd.normalize());      // sphere intersecting but moving away from each other already     if (vn &gt; 0.0f) return;      // collision impulse     float i = (-(1.0f + Constants.restitution) * vn) / (im1 + im2);     Vector2d impulse = mtd.normalize().multiply(i);      // change in momentum     this.velocity = this.velocity.add(impulse.multiply(im1));     ball.velocity = ball.velocity.subtract(impulse.multiply(im2));  }   Source Code:     If anyone has some suggestions for how to improve this basic physics simulator let me know!  One thing I have yet to add is angular momentum so the balls will roll more realistically.  Any other suggestions?  Leave a comment! Is it possible to turn off radio without turning of wifi on Lenovo k900? I am currently having a look at the power consumption of a lenovo k900 phone and on the hardware side it seems Radio and Screen is using most of the power.  I am planning to use wifi but not the radio. Are they disconnected ? If so, can I use just the wifi, but no radio/telephony ? Are the settings or commands/intents to access these settings ?  Thanks! Collection was modified; enumeration operation may not execute I can't get to the bottom of this error, because when the debugger is attached, it does not seem to occur.  Collection was modified; enumeration operation may not execute  Below is the code. This is a WCF server in a Windows service. The method NotifySubscribers() is called by the service whenever there is a data event (at random intervals, but not very often - about 800 times per day). When a Windows Forms client subscribes, the subscriber ID is added to the subscribers dictionary, and when the client unsubscribes, it is deleted from the dictionary. The error happens when (or after) a client unsubscribes. It appears that the next time the NotifySubscribers() method is called, the foreach() loop fails with the error in the subject line. The method writes the error into the application log as shown in the code below. When a debugger is attached and a client unsubscribes, the code executes fine. Do you see a problem with this code? Do I need to make the dictionary thread-safe? [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)] public class SubscriptionServer : ISubscriptionServer {     private static IDictionary&lt;Guid, Subscriber&gt; subscribers;      public SubscriptionServer()     {                     subscribers = new Dictionary&lt;Guid, Subscriber&gt;();     }      public void NotifySubscribers(DataRecord sr)     {         foreach(Subscriber s in subscribers.Values)         {             try             {                 s.Callback.SignalData(sr);             }             catch (Exception e)             {                 DCS.WriteToApplicationLog(e.Message,                    System.Diagnostics.EventLogEntryType.Error);                  UnsubscribeEvent(s.ClientId);             }         }     }          public Guid SubscribeEvent(string clientDescription)     {         Subscriber subscriber = new Subscriber();         subscriber.Callback = OperationContext.Current.                 GetCallbackChannel&lt;IDCSCallback&gt;();          subscribers.Add(subscriber.ClientId, subscriber);                  return subscriber.ClientId;     }      public void UnsubscribeEvent(Guid clientId)     {         try         {             subscribers.Remove(clientId);         }         catch(Exception e)         {             System.Diagnostics.Debug.WriteLine(&quot;Unsubscribe Error &quot; +                      e.Message);         }     } } Upgrading straight handlebars to drop handlebars I have a two-and-a-half year old  (with a road-bike-like frame and thin tires; it's somewhere in the loosely-defined "hybrid" range) that I use to commute to work, twenty-five miles round-trip, once or twice a week. The bike has straight handlebars, and having gotten used to the idea of commuting via bike, I'm interested in upgrading to drop handlebars. It looks like I'd need new break/shift levers to go with the handlebars; the whole upgrade looks like it'd run a couple hundred dollars. This is a sizable fraction of the original cost of the bike, which leads me to wonder if I'm better off saving my money for a new bike that's a little better adapted to my use.  Is upgrading my bike's handlebars a reasonable investment? Switch statement fallthrough in C#? How do I find out which version and derivative of Ubuntu is right for my hardware in terms of minimal system requirements? relative polar coordinates for TikZ elements in axis environment I would like to annotate a patch plot with lines whose start and end points are given in absolute polar and relative polar coordinates, respectively.  The patch plot, based on cartesian data, comes out as a circular shape centred around the origin (0,0) and shall be simulated here by a plain circle.  Lines should start at the circumference of the shape and point away from the shape under a given angle and have a well defined length. Therefore, the use of relative polar coordinates for the line's end point.  What seems to be straightforward with TikZ (left) fails inside the axis environment of pgfplots (right): neither the inclination angle nor the length of the line are correct if relative polar coordinates are used.    What is wrong with the rel. polar coordinates here?  The code:  \documentclass{standalone}  \usepackage{pgfplots} \pgfplotsset{compat=1.13}  \begin{document}  \begin{tikzpicture}   \draw(0,0) circle[radius=0.01];   \draw[blue] (0,0) circle[radius=1];   \draw[thick] (45:1) -- ++(45:0.5); \end{tikzpicture}  \begin{tikzpicture}   \begin{axis}[tiny,enlargelimits,   axis equal,   xmin=-2,xmax=2,   ymin=-1,ymax=1,   xtick={-2,-1,0,1,2},   ytick={-2,-1,0,1,2},   grid=major,   ]   \draw[blue] (0,0) circle[radius=1];   \draw[blue, dashdotted] (0,0) -- (45:2);   \draw[thick] (45:1) -- ++(45:0.5); %  \draw[thick] (45:1) -- (45:1.5); %absolute coordinates do work   \end{axis} \end{tikzpicture}  \end{document} I know from the  that it is not possible to introduce direct abbreviations like \newcommand{\bal}{\begin{align}} % doesn't work \newcommand{\eal}{\end{align}}   % doesn't work  or \newcommand{\bal}{\align}    % doesn't work \newcommand{\eal}{\endalign} % doesn't work  What is puzzling me is that \newenvironment{foo}{\align}{\endalign}  does work, at least if one is well-behaved enough to diligently type \begin{foo}...\end{foo}, since \foo...\endfoo won't work either. I'd really appreciate some help to shed some light on what is going on behind the scenes :-) \selectcolormodel{gray} doesn't work for the duck hair, but it works for the other parts of the ducks, why?  \documentclass{ltugboat}  \usepackage{microtype}  \usepackage{graphicx}  \usepackage{ifthen} \newboolean{grayscale}    \setboolean{grayscale}{true}% for the black &amp; white version    %\setboolean{grayscale}{false}% for the colored version     \usepackage{tikzducks} \usetikzlibrary{positioning}  \newenvironment{mytikz}{%     \begin{tikzpicture}     \ifthenelse{\boolean{grayscale}}{\selectcolormodel{gray}}{}      }     {\end{tikzpicture}}  \usepackage{ifpdf}  \ifpdf  \usepackage[breaklinks,hidelinks]{hyperref}  \else \usepackage{url} \fi   \begin{document}      Why \textbackslash\texttt{selectcolormodel\string{gray\string}} does not work for the duck hair?      Black and white version:          \begin{mytikz}         \begin{scope}[xscale=-1]             \duck[longhair=pink]         \end{scope}         \begin{scope}[xshift=10pt]             \duck[crazyhair=orange]         \end{scope}     \end{mytikz}      Colored version:     \setboolean{grayscale}{false}      \begin{mytikz}         \begin{scope}[xscale=-1]             \duck[longhair=pink]         \end{scope}         \begin{scope}[xshift=10pt]             \duck[crazyhair=orange]         \end{scope}     \end{mytikz} \end{document} I'm attempting to install Ubuntu 14.04.1 (the only version I have handy) onto my old Compaq Presario R3000 (this Ubuntu was recommended for this computer). The installation has stalled at about 60% and hasn't moved in an hour.  The message at the bottom says: Configuring bcmwl-kernal-source (i386).  I have no experience with Ubuntu (or with Linux, for that matter), coming from a strictly-Windows background). Can anyone offer some advice? Steam not opening in Ubuntu 16.04 LTS Escape Key in the Chat How to evaluate the integral $\int \sqrt{1+\sin(x)} dx$ To find:  $$\int \sqrt{1+\sin(x)} dx$$  What I  tried:  I put $\tan(\frac{x}{2}) = t$, using which I got it to:  $$I = 2\int \dfrac{1+t}{(1+t^2)^{\frac{3}{2}}}dt$$  Now I am badly stuck. There seems no way to approach this one. Please give a hint. Also, can we initially to some manipulations on the original integral to make it easy? Thank you. C# Equivalent of SQL Server DataTypes For the following SQL Server datatypes, what would be the corresponding datatype in C#?  Exact Numerics  bigint numeric bit smallint decimal smallmoney int tinyint money     Approximate Numerics  float real     Date and Time  date datetimeoffset datetime2 smalldatetime datetime time     Character Strings  char varchar text     Unicode Character Strings  nchar nvarchar ntext     Binary Strings  binary varbinary image     Other Data Types  cursor timestamp hierarchyid uniqueidentifier sql_variant xml table   (source: ) Take the manifold: The graph of $|x|$ on $(-1,1)$, with the induced topology from $\mathbb{R}^2$. This is a topological manifold, which is homeomorphic to $(-1,1)$ by projection. Is it a differentiable manifold? I believe it is, because we can take an atlas with only the projection, and then we will have only one transition map which is the identity, and therefore differentiable. But I'm not sure I get the definition of a differentiable manifold right...  Thanks!