adapter.getPosition return -1
How do I compare strings in Java?
Resources for Blender How do I use subprocess.Popen to connect multiple processes by pipes? How do I execute the following shell command using the Python  module?  echo "input data" | awk -f script.awk | sort &gt; outfile.txt   The input data will come from a string, so I don't actually need echo.  I've got this far, can anyone explain how I get it to pipe through sort too?  p_awk = subprocess.Popen(["awk","-f","script.awk"],                           stdin=subprocess.PIPE,                           stdout=file("outfile.txt", "w")) p_awk.communicate( "input data" )   UPDATE:  Note that while the accepted answer below doesn't actually answer the question as asked, I believe S.Lott is right and it's better to avoid having to solve that problem in the first place! For every matrix $A\in M_{2}( \mathbb{C}) $ there's  $X\in M_{2}( \mathbb{C})$ such that $X^2=A$? I am using a cloned hard drive in attempts to restore some old files.   The cloned drive has 2 users, one with an encrypted home drive, one without. Both are administrators. When I couldn't get into the main user (with the encrypted home directory), I logged in as the 2nd user and changed the password.   It seems that I somehow broke the relationship between the encryption passphrase and the user. I'm pretty sure I have the passphrase. Is there a way to get to the data? Optimal way to ignore duplicate inserts? Background  This problem relates to ignoring duplicate inserts using PostgreSQL 9.2 or greater. The reason I ask is because of this code:    -- Ignores duplicates.   INSERT INTO     db_table (tbl_column_1, tbl_column_2)   VALUES (     SELECT       unnseted_column,       param_association     FROM       unnest( param_array_ids ) AS unnested_column   );   The code is unencumbered by checks for existing values. (In this particular situation, the user does not care about errors from inserting duplicates -- the insertion should "just work".) Adding code in this situation to explicitly test for duplicates imparts complications.  Problem  In PostgreSQL, I have found a few ways to ignore duplicate inserts.  Ignore Duplicates #1  Create a transaction that catches unique constraint violations, taking no action:    BEGIN     INSERT INTO db_table (tbl_column) VALUES (v_tbl_column);   EXCEPTION WHEN unique_violation THEN     -- Ignore duplicate inserts.   END;   Ignore Duplicates #2  Create a rule to ignore duplicates on a given table:  CREATE OR REPLACE RULE db_table_ignore_duplicate_inserts AS     ON INSERT TO db_table    WHERE (EXISTS ( SELECT 1            FROM db_table           WHERE db_table.tbl_column = NEW.tbl_column)) DO INSTEAD NOTHING;   Questions  My questions are mostly academic:   What method is most efficient? What method is most maintainable, and why? What is the standard way to ignore insert duplication errors with PostgreSQL? Is there a technically more efficient way to ignore duplicate inserts; if so, what is it?   Thank you! Find the minimal polynomial for $\sqrt[3]{2} + \sqrt[3]{4}$ over $\mathbb{Q}$  I havent covered galois theory, this is an exercise from the chapter algebraic extensions in gallian.  I can see that $\sqrt[3]{2} + \sqrt[3]{4}$ $\in \mathbb{Q}(2^{1/3})$, after this I am clueless.  Need hints will finish the proof. My sister bought a used MacBook about 6 months ago and she has lost her password.  Here is the procedure I tried to use to reset the password:   Boot into single user mode (press Command-S at power on) Type fsck -fy Type mount -uw / Type launchctl load /System/Library/LaunchDaemons/com.apple.DirectoryServices.plist Type dscl . -passwd /Users/username password, replacing username with the targeted user and password with the desired password. Reboot   But when I try the step 4, it says launch_msg(): Socket is not connected.  I would like to know what command to enter in the single user mode to know what version the Macbook is running and the right command to reset the password. Thank you. The pronunciation of words which begins 'con' and 'com' Setting Zero values back to NULL Gradient descent and many other methods are useful for finding local minima in cost functions. They can be efficient when the cost function can be evaluated quickly at each point, whether numerically or analytically.    I have what appears to me to be an unusual situation. Each evaluation of my cost function is expensive. I am attempting to find a set of parameters that minimize a 3D surface against ground truth surfaces. Whenever I change a parameter, I need to run the algorithm against the entire sample cohort to measure its effect.  In order to calculate a gradient, I need to change all 15 parameters independently, meaning I have to regenerate all the surfaces and compare against the sample cohort way too many times per gradient, and definitely way too many times over the course of optimization.  I have developed a method to circumvent this problem and am currently evaluating it, but I am surprised that I have not found much in the literature regarding expensive cost function evaluations.  This makes me wonder if I am making the problem harder than it is and that there might be a better way already available.  So my questions are basically this: Does anyone know of methods for optimizing cost functions, convex or not, when evaluation is slow?  Or, am I doing something silly in the first place by rerunning the algorithm and comparing against the sample cohort so many times? Is there any connection between a matrix being invertible and being diagonalizable? Let $A$ be an $n\times n$ matrix.  If $A$ is invertible then one of it's eigenvalues is 0.  If $A$ is diagonalizable then it has $n$ linearly independent eigenvectors.   Are these two statements true? Is there any connection between them? May I infer one from the other? How do I manually install Adobe Flash player for Chromium? Show that $F\subset Y$ is closed in $Y$ iff $F=Y\;\cap\;H$ where $H\subset X$ is closed in $X$. I have the following problem:      Let $(X,\tau)$ be a topological space and $(Y,\tau_y)$ be its    subspace, that is $Y\subset X$ and $\tau_y=\{\;A\;\cap\;Y\mid  A\in\tau\;\}$. Let also $F\subset Y$ and $H\subset X$, where $H$ is    closed in $X$. Show that $F=Y\;\cap\;H$ if and only if $F$ is closed   in $Y$.   I solved this problem by assuming that if $F$ is closed then $F=Y\;\cap\;H$, where $H$ is closed in $X$, but I got stuck proving this in the other direction, that is showing that if $F=Y\;\cap\;H$ then $F$ is closed in $Y$.  I tried to do something like this:   Assumption: $F=Y\;\cap\;H$, where $H$ is closed in $X$. If $H$ is closed in $X$ then $X\;\setminus\;H$ is open in $X$ and then $X\;\setminus\;H \in \tau$ which means that $B = (X\;\setminus\;H)\;\cap\;Y\in \tau_y$.  How should I proceed now? Should I investigate the set $B$ now more or what? Chat related privileges are not site specific Is this study stating red algae reduces cold virus by 92% believable? I was using this spray meant to hasten recovery from the common cold. , sponsored by the pharmaceutical company that produces the spray, stated it reduced virus by 92%, and so shortens the duration of the common cold.  Meanwhile a doctor told me that these kinds of things don't work.  Does someone have some perspective on this? Is this a believable study? Was it well designed, and has it been duplicated?   If so, why wouldn't the pharmaceutical produced a certified and expensive drug instead of a no-prescription drug? Compound possessives and yours Problem: Let $f$ be defined for all real $x$, and suppose that   $$|f(x)-f(y)|\le (x-y)^2$$  for all real $x$ and $y$. Prove $f$ is constant.  Source: W. Rudin, Principles of Mathematical Analysis, Chapter 5, exercise 1. Is the product of two Gaussian random variables also a Gaussian? Say I have $X \sim \mathcal N(a, b)$ and $Y\sim \mathcal N(c, d)$.  Is $XY$ also normally distributed?  Is the answer any different if we know that $X$ and $Y$ are independent? Check if this proof about real numbers with an irrational product is correct. Can anyone confirm if my proof is correct, please?  Claim:- “If $x$ and $y$ are real numbers and their product is irrational, then either $x$ or $y$ must be irrational.”  Proof:-   Assume that both $x$ and $y$ are rational. Now, let $x = \dfrac pq$ and $y = \dfrac mn$ since both of them are rational. $xy =\dfrac pq * \dfrac mn = \dfrac{pm}{qn}$ Thus, if the product $xy$ can be written as a fraction, it's not a irrational number. Therefore if one of $x$ and $y$ is not irrational, then the product is not irrational.  By the principle of proof by contraposition, If $x$ and $y$ are real numbers and their product is irrational, then either $x$ or $y$ must be irrational. What is difference between: "I have been married with (was married with, married) her for three years." What is the difference between the three sentences below?   I have been married with her for three years. I was married with her for three years. I married her for three years.