Interface programming for LinkedLists
What does it mean to "program to an interface"?
Marketing Cloud Mobile Push SDK - Switching app user I'm currently building a clienteling app that integrated the Mobile Push SDK on both iOS and Android and encountered some issue on switching the account.  I found that when I login to user A, and set contact key to A, the Inbox Messages will be send to this device. However, I logout user A and switch to a user B, I should set the contact key to B. But seems the inbox messages are associated with the Device instead of Contact, I can still see the inbox messages that were sent to contact A previously.  My question is, how should we deal with this situation, to prevent from seeing the previous inbox messages if the contact key has been changed? Alignment of equals sign in multiple align environments Sharing a Bluetooth Keyboard and Mouse sequentially between two Macs I work out of my house where I have two computers: a mid-2010 Macbook Pro (for my day job) and a mid-2010 iMac (personal). During the workday, my iMac acts as a second display for my Macbook Pro via Mini Displayport.  Currently, I use a USB keyboard and mouse for my work computer and a Bluetooth keyboard and Magic Mouse + Magic Trackpad for use with my personal computer. I'd like to get rid of the wired keyboard and mouse and just use the Bluetooth stuff for both machines (but never simultaneously).   Is it possible to easily share the single set of input devices without having to repeatedly break and reestablish the pairing of the input device to the correct computer? I'm not opposed to buying some type of additional hardware to accomplish this, provided it's not prohibitively costly or cumbersome to use or configure.  It's not clear to me how I would tell the MacBook Pro to leave the devices alone so the iMac can have them for the evening. I want to avoid de-pairing and re-pairing the devices each time I want to shift them back or forth.  Basically is there software or hardware that works as a Bluetooth KVM switch? Output of Logistic Regression Prediction Dataset collapsing/reducing I'm having a lot of trouble figuring this one out.  Determine if  $\sum_{i=2}^{\infty} \frac{(-1)^n}{n+(-1)^n}$ converges or diverges  Both ratio and root test are inconclusive and I'm at a loss. Can anyone help me? Are there any XSLT processing command line tools? How to run a command that requires sudo at login SBS 2011 - Is Store.exe High Memory Usage Normal? 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? I want to output two different views (one as a string that will be sent as an email), and the other the page displayed to a user.  Is this possible in ASP.NET MVC beta?  I've tried multiple examples:  1.      If I use this example, I receive the "Cannot redirect after HTTP   headers have been sent.".   2.      If I use this, I seem to be unable to do a redirectToAction, as it   tries to render a view that may not exist. If I do return the view, it   is completely messed up and doesn't look right at all.   Does anyone have any ideas/solutions to these issues i have, or have any suggestions for better ones?  Many thanks!  Below is an example. What I'm trying to do is create the GetViewForEmail method:  public ActionResult OrderResult(string ref) {     //Get the order     Order order = OrderService.GetOrder(ref);      //The email helper would do the meat and veg by getting the view as a string     //Pass the control name (OrderResultEmail) and the model (order)     string emailView = GetViewForEmail("OrderResultEmail", order);      //Email the order out     EmailHelper(order, emailView);     return View("OrderResult", order); }   Accepted answer from Tim Scott (changed and formatted a little by me):  public virtual string RenderViewToString(     ControllerContext controllerContext,     string viewPath,     string masterPath,     ViewDataDictionary viewData,     TempDataDictionary tempData) {     Stream filter = null;     ViewPage viewPage = new ViewPage();      //Right, create our view     viewPage.ViewContext = new ViewContext(controllerContext, new WebFormView(viewPath, masterPath), viewData, tempData);      //Get the response context, flush it and get the response filter.     var response = viewPage.ViewContext.HttpContext.Response;     response.Flush();     var oldFilter = response.Filter;      try     {         //Put a new filter into the response         filter = new MemoryStream();         response.Filter = filter;          //Now render the view into the memorystream and flush the response         viewPage.ViewContext.View.Render(viewPage.ViewContext, viewPage.ViewContext.HttpContext.Response.Output);         response.Flush();          //Now read the rendered view.         filter.Position = 0;         var reader = new StreamReader(filter, response.ContentEncoding);         return reader.ReadToEnd();     }     finally     {         //Clean up.         if (filter != null)         {             filter.Dispose();         }          //Now replace the response filter         response.Filter = oldFilter;     } }   Example usage  Assuming a call from the controller to get the order confirmation email, passing the Site.Master location.  string myString = RenderViewToString(this.ControllerContext, "~/Views/Order/OrderResultEmail.aspx", "~/Views/Shared/Site.Master", this.ViewData, this.TempData); Regular (non-moderator) users should be able to override deletions by Community user There is a question on  that got deleted by the Community user. This question isn't terrible (we have worse one's there), and I'm not complaining about this question in particular.  I wanted to vote to undelete it. However, it says "A moderator has deleted this post and it cannot be undeleted". This "moderator" is Community!  I understand if a "real" live human moderator (no offense to all non-humans out here) deleted this question that we can't override it. But this is a Robot! It sees that it got a downvote, no answer and little activity for a while and just deletes it.  Can we have "Community user" have rights to delete, but have those "deletions" subject to normal-person override? Command for taking a screenshot to a new file How to define binary operation on arbitrary set in order to create a group structure. How can I remove all duplicates so that NONE are left in a data frame? Switching OS remotely using TeamViewer I have a dual boot system with Ubuntu 16.04 and Windows 7. Windows 7 is automatically booted (default in the bootloader). On both OS I have TeamViewer installed.  When I'm working remotely and want to switch to Ubuntu I have to reboot the PC but then automatically Windows is booted again (I'm not in front of the PC, so I cannot use the bootloader). How can I in such a case switch to Ubuntu, i.e. starting Ubuntu? And how can I switch back to Windows? Uncertainty modeling for samples I have instances of data that are composed of 6 attributes. Each attribute takes values between 1-10. Any instance has a utility calculated by some utility function:  Example: {1,1,2,5,5,2} , utility = 0.89  In some readings for these attribute values, undefined values may appear in the instance, I mark them as question mark '?'  Example: {1,1,?,5,?,2}  These question marks represents uncertainty in the instance.  How can I model this uncertainty in a statistical or mathematical way ?   Thanks Let $X_1$ and $X_2$ be two independent exponential random variables with the PDFs $f_{X_1}(x_1)=\lambda_1 \exp(-\lambda_1 x_1)$ and $f_{X_2}(x_2)=\lambda_2 \exp(-\lambda_2 x_2)$.   Let $X= \frac{X_1X_2}{X_1+X_2+a}$ be a r.v. for which I want to derive the CDF, where $a$ is a positive constant.  In other words, I need to calculate $\mathbb{P}\{X &lt;x \}$.  Any ideas or hints?  Edit (attempt):  Using a similar approach to that used , we have $X_1 \in [0, \infty)$ and  $X_2 \in [0, \frac{x(x_1+a)}{x_1-x})$. The latter interval results from: $\frac{x_1x_2}{x_1+x_2+a} &lt; x$, thus $x_2(x_1-x)&lt;x(x_1+a)$ which implies $x_2 &lt; \frac{x(x_1+a)}{x_1-x}$; but I am not sure if this is correct since $x_1-x$ can sometimes be negative (?). Based on the above, we can write: \begin{align}  \mathbb{P} \{ \frac{X_1X_2}{X_1+X_2+a} &lt; x \}  &amp; = \int_{x_1=0}^\infty \int_{x_2=0}^{ \frac{x(x_1+a)}{x_1-x}} \lambda_1 \exp(-\lambda_1 x_1) \lambda_2 \exp(-\lambda_2 x_2)  dx_2 dx_1  \\ &amp;= \int_{x_1=0}^\infty \left(1-\exp(-\lambda_2\frac{x(x_1+a)}{x_1-x}) \right) \lambda_1 \exp(-\lambda_1 x_1) dx_1  \\ &amp; = 1-\lambda_1 \int_{x_1=x}^\infty \exp(-\lambda_2\frac{x(x_1+a)}{x_1-x} ) \exp(-\lambda_1 x_1)   dx_1 \end{align} In the last equality: for the integral of $\lambda_1 \exp(-\lambda_1 x_1) dx_1$, I suppose that $x_1 \in [0,\infty)$, whereas for the second term I suppose that $x_1 \ge x$ (since $x_2$ should be positive) (?).  Is my approach correct ? Performance impact of updating target columns with same values ON CONFLICT This is a question about the inner-workings of Postgres (v10) and performance.  Given a table, github_repos, with a multi-column unique index on org_id and github_id columns, is there any performance difference (or other issues to be aware of) between the two bulk upsert operations below? The difference is that in the first query, the org_id and github_id columns are included in the UPDATE, whereas in the second query they are not. Since the UPDATE runs ON CONFLICT, the updated values of org_id and github_id will be the same as the old values, but those columns are included in the UPDATE because the underlying library I am using is designed that way. I'm wondering if its safe to use as-is or whether I should be explicitly excluding those columns in the UPDATE.  Query #1:  INSERT INTO "github_repos" ("org_id","github_id","name") VALUES (1,1,'foo') ON CONFLICT (org_id, github_id) DO UPDATE SET "org_id"=EXCLUDED."org_id","github_id"=EXCLUDED."github_id","name"=EXCLUDED."name" RETURNING "id"   Query #2:  INSERT INTO "github_repos" ("org_id","github_id","name") VALUES (1,1,'foo') ON CONFLICT (org_id, github_id) DO UPDATE SET "name"=EXCLUDED."name" RETURNING "id"   github_repos table:        Column       |       Type        | Collation | Nullable  -------------------+-------------------+-----------+----------+  id                | bigint            |           | not null |  org_id            | bigint            |           | not null |  github_id         | bigint            |           | not null |  name              | character varying |           | not null |  Indexes:     "github_repos_pkey" PRIMARY KEY, btree (id)     "unique_repos" UNIQUE, btree (org_id, github_id) It seems Microsoft has tried to solve this problem .  In Windows 7, there is no boundary between monitors and the mouse can move freely across the top of the screen between my 3 monitors, provided I had set their heights equal in display settings. Windows 8 introduced sticky corners. See .  Windows 10 got sticky corners as well. There are a few pixels at the top corners of each display where the mouse cannot cross over onto the other display. One must move the cursor down to avoid this region in order to get to the next display.  The image shows roughly the region where mouse movement is not permitted in Windows 10, but is allowed in Windows 7.    Personally, I had no problem with unrestricted mouse movement across the top of my screens - I got used to "aiming" for the x, and the convenience of unrestricted cursor movement. Like all the people who wanted to disable it in W8, I'm wondering if there is a way to disable it in W10.  Edit to address possible duplicate:  Although the problem is identical to the one in , solutions to solve the problem in W8 involving editing the registry key MouseCornerClipLength do not work in W10, since that registry key is not present in W10. Also adding that key and setting the value doesn't work. I searched the entire registry and couldn't find it in another location. No other W10 keys in the node referenced in the W8 solution are obvious replacements.  Edit to address possible solutions in comments  harrymc's  and  that worked for for Windows 8.1 do not work in Windows 10.