Suppose I have a list of integers:  myList = [1,2,3,4]   How would one return every possible combination of these two subsets with Python.  For example, set [1,2,3,4] would produce [1,2], [3,4] and [1,3], [2,4] and [1,4],[2,3]
I have a list with 15 numbers in, and I need to write some code that produces all 32,768 combinations of those numbers.   I've found  (by Googling) that apparently does what I'm looking for, but I found the code fairly opaque and am wary of using it. Plus I have a feeling there must be a more elegant solution.  The only thing that occurs to me would be to just loop through the decimal integers 1–32768 and convert those to binary, and use the binary representation as a filter to pick out the appropriate numbers.   Does anyone know of a better way? Using map(), maybe?
Is there any benefit of creating model in one piece or I can create separate pieces and just overlap them to create a visually joint part.  For example, the below image were made from two parts 1. Blade 2. Spinner  Is there any benefit to model them (e.g. extrude from the spinner) or it is actually ok to have them separated since visually I can achieve the same effect (See picture 2) Why can't I run two mysqli queries? The second one fails Git - how to force merge conflict and manual merge on selected file Need help disabling imessage? I recently changed from iphone to android and i have been having trouble recieving messages from my iphone friends since my iphones screen is broken i cant do anything on it. Any way to fix this problem through icloud or something? Which is the preferred way to convert an Enum to a String in .NET 3.5?   Enum.GetName Enum.Format ToString   Why should I prefer one of these over the others? Does one perform better? I bought an audio book from audible and want to convert it to mp3 from aa because my phone doesn't support the format. Is there any way to do that? What is the relationship between ISO, aperture, and shutter speed? pgfpages and section I'm making a Beamer presentation. I need to show some notes on a second screen, so I'm using pgfpages.  Whereas, when I put a section, it appears 2 times :/ Here, it's a minimal code with the problem. Have you any idea ?  \documentclass{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} \usepackage[francais]{babel}  \usepackage{pgfpages} \setbeameroption{show notes on second screen=right}    \begin{document} \begin{frame} \tableofcontents \end{frame}  \begin{frame} \section{test} toto \end{frame}  \end{document}   Thanks ! Android: How to draw route directions google maps API V2 from current location to destination How can I add left aligned text to an equation? I have a document I am trying to copy to learn TeX. Here is what I have encountered: How can I have the "or" in the equation. This is what I have right now:  \[ f = ma; \]  But $a$ is the change in velocity,  \[ f = m \frac{dv}{dt};\] \[ f = m  \frac{d^2y}{dt^2};\]   Edit: Trying out Stefan's answer I need to create an edit component for an SObject from which I do not know the objectApiName at design time. I only know the Id of the SObject. objectApiName could be any valid SObject-name.  Now I want to use lightning:inputField   This needs to be wrapped by lightning:recordEditForm  In case I hardcode it to "Order", provide a vaild Order Id and let the controller load the order and assign it to the Parent-attribute, this works flawlessly:  &lt;aura:attribute name="recordId" type="String" default="" /&gt; &lt;aura:attribute name="Parent" type="SObject" default="{}" /&gt; &lt;aura:attribute name="ParentType" type="String" default="" /&gt; &lt;b&gt;{!v.ParentType}({!v.recordId})&lt;/b&gt; &lt;br/&gt; &lt;lightning:recordEditForm recordId="{!v.recordId}"  objectApiName="Order"&gt;     &lt;lightning:messages /&gt;     &lt;lightning:inputField fieldName="Name" /&gt;     &lt;lightning:button class="slds-m-top_small" variant="brand" type="submit" name="update" label="Update" /&gt; &lt;/lightning:recordEditForm&gt;   It looks like below and even the Update-button works as expected and saves the record:    But what I really want is  &lt;lightning:recordEditForm recordId="{!v.recordId}"  objectApiName="{!v.ParentType}"&gt;   Note the {!v.ParentType} instead of the hardcoded "Order"  As an great unfortunate, this only collapses to that error-popup    In the screenshot you see, that the ParentType is correctly bound to v.ParentType (right above the button) which a I also verify in the console  Suspicion  I set the ParentType-attribute as a result of APEX call (asynchronously). This seems to be too late for the lightning:recordEditForm. It tries to render with objectApiName at a time where it is still blank, hence it crashes during initialization...  Question  Is there a clean way to avoid this and get something to fly with an dynamic objectApiName?  Trying to use $A.createComponents()  As @sfdcfox suggested I jump on the $A.createComponents() which turned indeed out to be tricky, exactly as sfdcfox has predicted. Im following this .  Added a button to the markup    Added a handler to the js-controller:  makeEdit : function(cmp, evt, hlp) {      console.log('ParentId :: ', cmp.get("v.ParentId") );      console.log('ParentType :: ', cmp.get("v.ParentType") );      $A.createComponents([             ["lightning:recordEditForm",{                 "recordId"          : cmp.get("v.ParentId"),                 "objectApiName"     : cmp.get("v.ParentType"),             }],             ["lightning:inputField",{                 "fieldName" : "Name"             }]         ]         ,function(components, status, errorMessage){             if (status === "SUCCESS") {                 var wrapper         = components[0];                 var inner           = components[1];                 wrapper.set("v.body", inner);             }             else if (status === "INCOMPLETE") {                 console.log("No response from server or client is offline.")                 // Show offline error             }             else if (status === "ERROR") {                 console.log("Error: " + errorMessage);                 // Show error message             }         }     ); },   Now I can press the button - but nothing - I repeat: n o t h i n g - gets rendered at all. What is my fault here? Note that the console.log get output and the attribute are holding good values. Two icons on Unity Launcher on non-standard application launch I have an application which doesn't come from any Ubuntu repo (neither official, nor PPA) but available as tgz and supposed to be unpacked and ready to use. To be precise it is .   The problem is the  application when launched shows its own icon in Unity Launcher. After making a custom .desktop file and placing shortcut onto Unity Launcher (by dragging from the dash) and launching it I see two icons - one placed by me and another one with real application.  This is the .desktop contents:  [Desktop Entry] Version=1.0 Type=Application Terminal=false Exec=/opt/LightTable/LightTable Name=Light Table Icon=/opt/LightTable/core/img/lticon.png   One more thing. The /opt/LightTable/LightTable is bash script file and eventually /opt/LightTable/ltbin is being launched. I think this is the problem but have no idea how to fix the problem. Computing the best constant in classical Hardy's inequality Classical Hardy's inequality (cfr. Hardy-Littlewood-Polya Inequalities, Theorem 327)  If $p&gt;1$, $f(x) \ge 0$ and $F(x)=\int_0^xf(y)\, dy$ then   $$\tag{H} \int_0^\infty \left(\frac{F(x)}{x}\right)^p\, dx &lt; C\int_0^\infty (f(x))^p\, dx $$  unless $f \equiv 0$. The best possibile constant is $C=\left(\frac{p}{p-1}\right)^p$.   I would like to prove the statement in italic regarding the best constant. As already noted by Will Jagy , the book suggests stress-testing the inequality with   $$f(x)=\begin{cases} 0 &amp; 0\le x &lt;1 \\ x^{-\alpha} &amp; 1\le x \end{cases}$$   with $1/p&lt; \alpha &lt; 1$, then have $\alpha \to 1/p$. If I do so I get for $C$ the lower bound  $$\operatorname{lim sup}_{\alpha \to 1/p}\frac{\alpha p -1}{(1-\alpha)^p}\int_1^\infty (x^{-\alpha}-x^{-1})^p\, dx\le C$$  but now I find myself in trouble in computing that lim sup. Can someone lend me a hand, please?    UPDATE: A first attempt, based on an idea by Davide Giraudo, unfortunately failed. Davide pointed out that the claim would easily follow from   $$\tag{!!} \left\lvert \int_1^\infty (x^{-\alpha}-x^{-1})^p\, dx - \int_1^\infty x^{-\alpha p }\, dx\right\rvert \to 0\quad \text{as}\ \alpha \to 1/p. $$  But this is false in general: for example if $p=2$ we get   $$\int_1^\infty (x^{-2\alpha} -x^{-2\alpha} + 2x^{-\alpha-1}-x^{-2})\, dx \to \int_1^\infty(2x^{-3/2}-x^{-2})\, dx \ne 0.$$ Unfortunately, despite having tried to learn regex at least one time a year for as many years as I can remember, I always forget as I use them so infrequently. This year my new year's resolution is to not try and learn regex again - So this year to save me from tears I'll give it to Stack Overflow. (Last Christmas remix).  I want to pass in a string in this format {getThis}, and be returned the string getThis. Could anyone be of assistance in helping to stick to my new year's resolution?    Related questions on Stack Overflow: MySQL convert date string to Unix timestamp New UI encourages askers to confirm or dispute duplicate votes With powershell get exactly the same application list as in Add/Remove programms There are various methods to find installed applications on the system but to my knowledge none returns exactly the same list as control panel item Add Remove Programs. Some of the ways I tried are:   WMI via Win32_Product and Win32Reg_AddRemovePrograms Registry, both x32 and x64 branches   For instance, I have 217 entries in AR and   gwmi  Win32_Product   returns 261 items.  gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | ? {![string]::IsNullOrWhiteSpace($_.DisplayName) } | select DisplayName   returns 119 items.   (gwmi Win32Reg_AddRemovePrograms) + (gwmi Win32Reg_AddRemovePrograms64) | sort DisplayName -Unique    returns 107 items.  I tried to nail it down with more complex filter that included InstallLocation, InstallSource, InstallDate etc without success. Can someone tell me what is wrong with this loop?    The error that I have is on the line 107 (first line of the loop). It says:      [V2016057174800: command not found.    I am trying to associate two the same filename from two different documents (if that makes sense). In France the higher education is like this:   3 years of "Licence" 2 years of "Master" 3 years of "Doctorat"   But what about in the United States?  I heard that they have things called "undergraduate", "graduate" and "postgraduate". How many years do each of those take? And what are the equivalencies between these and the "Licence - Master - Doctorat"?  Note: If the answer to this question depends on the field of studies, then the field is physics. Is a memory leak created if a MemoryStream in .NET is not closed? I have the following code:  MemoryStream foo(){     MemoryStream ms = new MemoryStream();     // write stuff to ms     return ms; }  void bar(){     MemoryStream ms2 = foo();     // do stuff with ms2     return; }   Is there any chance that the MemoryStream that I've allocated will somehow fail to be disposed of later?    I've got a peer review insisting that I manually close this, and I can't find the information to tell if he has a valid point or not.