For example, I have a string, "     some string", and I want to put "some string" in another string variable. How do I do that?  My code:  function get_title() {     t1=$(get_type "$1")     t2="ACM Transactions"     t3="ELSEVIER"     t4="IEEE Transactions"     t5="MIT Press"     if [ "$t1"=="$t2" ];         then         title=$(less "$1" | head -1)     elif [ "$t1"=="$t5" ];     then         title=$(less "$1" | head -3)     fi     echo "$title" }   As you can see the $title can return unwanted whitespace in front of text in center aligned texts. I want to prevent that.
I have a shell script with this code:  var=`hg st -R "$path"` if [ -n "$var" ]; then     echo $var fi   But the conditional code always executes, because hg st always prints at least one newline character.   Is there a simple way to strip whitespace from $var (like trim() in )?   or   Is there a standard way of dealing with this issue?   I could use  or , but I'd like to think there is a more elegant solution to this problem.
MySQL not using indexes with WHERE IN clause? What are good ways to make pdflatex output copy-and-pasteable? One frequent aspect of pdflatex output that could be improved is to what extent one can select text output from the generated pdf-file and copy-and-paste it. This is essentially an issue of having the right output encoding. There are at least two important aspects to this:   In the ideal case, Unicode would be the output encoding. Ligature glyphs (such as ﬁ) are ideally de-ligated in the output (here: "fi").   It seems that output encodings are specified through the fontenc package. What is the range of possible output encodings, and most importantly: Is there a way to specify a Unicode output encoding and one that deals with ligatures in the intended way?  (Note: It is important to distinguish output from input encodings. How to use different input encodings in LaTeX has been documented widely. My understanding is that this is best handled by the inputenx package, as it supersedes the inputenc package.)    Quick guide to the solutions: The information in the answers and answer threads is a bit distributed, so here the short summary: one approach is to use \input glyphtounicode together with \pdfgentounicode=1; the other approach is to use cmap/mmap.  Addendum: Sometimes one will need to load the package accsupp and enclose one's macro definition in \BeginAccSupp{method=hex,unicode,ActualText=&lt;codepoint&gt;}[...]\EndAccSupp{} to generate a specific code point. See the caveat about non-BMP code points  and the fix (starting from accsupp version v0.4, 2012/11/18) , which provides the new unichar package option. How to determine if $n (n \geq 2)$ given numbers can be summed up to a certain number? I'm interested in knowing if there's a theorem for checking if combinations of $n$ given positive numbers can be summed up to a certain number.   For example, if I was given $n = 2$ numbers, which are $k_1$ and $k_2$, and I was asked if I could make a combination like $n_1 * k_1 + n_2 *k_2 = C$, all $\in \mathbb{N}^+$, I could check remainders to see if it is possible.   However, if $n = 3$ or higher, how could I check if combinations of $k_1, k_2, ..., k_n$ can be summed up to a $C$? Thank you for any inputs! Change the selected value of a drop-down list with jQuery I have a drop-down list with known values. What I'm trying to do is set the drop down list to a particular value that I know exists using jQuery.  Using regular JavaScript, I would do something like:  ddl = document.getElementById("ID of element goes here"); ddl.value = 2; // 2 being the value I want to set it too.   However, I need to do this with jQuery, because I'm using a CSS class for my selector (stupid  client ids...).  Here are a few things I've tried:  $("._statusDDL").val(2); // Doesn't find 2 as a value. $("._statusDDL").children("option").val(2) // Also failed.      How can I do it with jQuery?     Update  So as it turns out, I had it right the first time with:  $("._statusDDL").val(2);   When I put an alert just above it works fine, but when I remove the alert and let it run at full speed, I get the error     Could not set the selected property. Invalid Index   I'm not sure if it's a bug with jQuery or Internet Explorer 6 (I'm guessing Internet Explorer 6), but it's terribly annoying. 14.04 --> 16.04 failed; apt (>= 1.0.1ubuntu2.13)' is not installed (This question was not resolved. Due to time constraints Computer was restored to factory settings.)  I was attempting to upgrade from 14.04 to 16.04, but apt threw this error:  The required dependency 'apt (&gt;= 1.0.1ubuntu2.13)' is not installed.   What does this mean, and how can I fix it?  When I type in the command apt-cache policy apt  Shageenth@shageenth-Inspiron-3451:~$ apt-cache policy apt apt: Installed: 1.0.1ubuntu2.11 Candidate: 1.0.1ubuntu2.11 Version table: *** 1.0.1ubuntu2.11 0 100 /var/lib/dpkg/status 1.0.1ubuntu2 0 500 http://us.archive.ubuntu.com/ubuntu/ trusty/main amd64  Packages   The error happens when I run the command:   sudo do-release-upgrade -d   and it produces the following:  Checking for a new Ubuntu release Get:1 Upgrade tool signature [198 B] Get:2 Upgrade tool [1,265 kB] Fetched 1,265 kB in 0s (0 B/s) authenticate 'xenial.tar.gz' against 'xenial.tar.gz.gpg' extracting 'xenial.tar.gz'  Reading cache  Checking package manager Reading package lists... Done Building dependency tree Reading state information... Done Building data structures... Done  Required depends is not installed  The required dependency 'apt (&gt;= 1.0.1ubuntu2.13)' is not installed. How can a function with a hole (removable discontinuity) equal a function with no hole? I've done some research, and I'm hoping someone can check me. My question was this:  Assume I have the function $f(x) = \frac{(x-3)(x+2)}{(x-3)}$, so it has removable discontinuity at $x = 3$. We remove that discontinuity with algebra: $f(x) = \frac{(x-3)(x+2)}{(x-3)} = (x+2)$. BUT, the graph of the first function has a hole at $x = 3$, and the graph of the second function is continuous everywhere. How can they be "equal" if one has a hole and the other does not?  I think that this is the answer:   Because the original function is undefined at the point $x = 3$, we have to restrict the domain to $\mathbb{R} \setminus 3$. And when we manipulate that function with algebra, the final result, $f(x) = (x + 2)$ is still using this restricted domain. So even though the function $f(x) = (x+2)$ would not have a hole if the domain were all of $\mathbb{R}$, we are sort of "imposing" a hole at $x = 3$ by continuing to throw that point out of the domain.   And then just to close the loop: Removing the removable discontinuity is useful because it allows us to "pretend" that we're working with a function that is everywhere continuous, which helps us easily find the limit. But the reality is that the function $f(x) = (x +2)$ is actually NOT continuous everywhere when we restrict the domain by throwing out the point 3. Or am I now taking things too far?   Thanks in advance!  EDIT: For anyone coming across this in the future, in addition to the excellent answers below, I also found this other question about the  helpful. in elisp's let, how do you reference a variable bound in the same let while binding another variable? Why does the Euclidean algorithm work for polynomials? What is the proof? How to simulate data that satisfy specific constraints such as having specific mean and standard deviation? The separation between the two plates of a capacitor is increased I had the following question on a quiz recently:     A capacitor consisting of two parallel plates, separated by a distance $d$, is connected to a battery of EMF ε. What happens if the separation is doubled while the battery remains connected?    The correct answer was "The electric charge on the plates is halved." However, we were previously given a question in which a circuit consists of a capacitor of 6 μF and a resistor of 300,000 Ω connected to a battery, and the separation between the plates of the capacitor is quadrupled. However, in this circumstance, the charge on the capacitor immediately after the plates are separated remains the same, and the potential difference across the capacitor increases.   I am confused as to why these questions have different answers to them, despite having an extremely similar setup. My best guess is that the circuit in the second question also has a resistor, but I am not sure, and help would be greatly appreciated. Pushforward of inverse map at the identity? Let $G$ be a Lie group and $i:G \rightarrow G$ denote the inversion map $i(x) = x^{-1}$. (Notation: $f_*$ is the pushforward map $F_*:T_pG \rightarrow T_{i(p)}G$ which takes $(F_{*}X)(f)=X(f\circ F)$ and $X$ is a tangent vector, $X\in T_pG$.) I wish to show that $i_{*}:T_{e}G\rightarrow T_{e}G$  is given by $i_{*}(X)=-X$ As a first step, it is trivial to prove that $i_*$ is an involution as $\mbox{Id}_{*}=(i\circ i)_{*}=i_{*}\circ i_{*}$ but I can't seem to make any further progress. Any help would be appreciated. Lately it's happening to me this:  After completing one or more "First Posts" reviews, I go back to the Review Section main page:   And the post counter shows that there are still posts to review. I click the link to review them, but there is nothing.  Refreshing the page doesn't solve the issue: it shows the wrong number again. Is there a *simple* example showing that uncorrelated random variables need not be independent? Create instance of generic type in Java? Is it possible to create an instance of a generic type in Java? I'm thinking based on what I've seen that the answer is no (due to type erasure), but I'd be interested if anyone can see something I'm missing:  class SomeContainer&lt;E&gt; {     E createContents()     {         return what???     } }   EDIT: It turns out that  could be used to resolve my issue, but it requires a lot of reflection-based code, as some of the answers below have indicated.  I'll leave this open for a little while to see if anyone comes up with anything dramatically different than Ian Robertson's . Add table row in jQuery What is the best method in jQuery to add an additional row to a table as the last row?  Is this acceptable?  $('#myTable').append('&lt;tr&gt;&lt;td&gt;my data&lt;/td&gt;&lt;td&gt;more data&lt;/td&gt;&lt;/tr&gt;');   Are there limitations to what you can add to a table like this (such as inputs, selects, number of rows)? How to fix java.net.SocketException: Broken pipe? Getting started with ArcObjects? What is the best route or place to get started with ArcObjects if one is not a developer and not aiming to become a developer?  I've been using gis professionally for a long time, almost two decades, arcinfo/arcgis for most of that; I'm pretty good. I'm learning software development, and even have a modestly successful small python application used in a public project; I'm not good! I don't want to become a full fledged software developer but I keep running into things I just can't do without programming (). In the arcgis world this puts me pretty squarely in the python camp, which is fine by me since I like python, however python does not have straightforward access to ArcObjects. (Python and ArcObjects , but it's an unsupported route. This question is about following a beaten path.)  I need to get started, but where?  to get started with the  but $1500/yr is definitely not in my budget, and sounds like using a sledge hammer to swat mosquitos. And which language .NET, Visual Basic, or Visual C++?    UPDATE: Thank you everyone for the wonderful answers. In light of them I realise  I unecessarily narrowed the scope of my question be pre-supposing "ArcObjects" is the direction I need to go in. A more open ended formulation is more along the lines of:     I keep running into problems I just   can't solve with arcgis and python   alone. What else can I learn/use to   solve problems like X? I've no   interest or intention of becoming a   software developer. I just need to do   a couple things which aren't exposed   to the arcgis python modules. What is the difference between .profile and .bash_profile and why don't I have a .profile file on my system? So I'm pretty new to Linux and recently installed Fedora 19 on my netbook. I want to have a deeper understanding of Linux and the CLI so I'm now reading .  In exercise 3 the author gives the following commands:   ls -al cat .profile   I try to follow these instructions but to no avail. There is no .profile file in my user name directory as I can see from ls -al. From what I've learned the .bash_profile and .profile file are practically the same. The only difference I concluded from my research is that .bash_profile gets checked first.   What I don't understand is why are there multiple files for the same function in Linux, why is the Author using .profile and not .bash_profile (if I understand correctly .profile won't be read when the system finds .bash_profile first) and how comes that I don't have the .profile file on my system? Resizing or expanding a CoreStorage volume Can't we compute $\lim_{n \to \infty}\frac{1+ \cdots +n}{n^2}=\lim_{n\to\infty}\frac{1}{n^2}+\cdots +\lim_{n\to\infty}\frac{n}{n^2}=0$?