I have two files: a.patterns contains patterns in a one per line way  "`" "^" "&lt;" "&lt;(" "&lt;)" "&lt;[" "=" "&gt;" "_;|^+*+?@"   and b.data contains comma separated values.  1,1,0,"*",1 2,1,1,"*",1 3,0,0,"&lt;)",0   The purpose is to substitute take each pattern matched in the csv file with that pattern's index (i.e., its line number).   The problem is that I load each pattern into a variable, and use sed to evaluate/replace it but frequently the patterns contain special characters.   ... while read line; do   counter=`expr $counter + 1`   temp=`echo "$temp" | sed "s/$line/$counter/"` done &lt; a.patterns ...   My question: is there a way to tell sed to count the contents of the variable as literals? Ideally I would like to avoid inserting escape character for all special characters in the pattern file or alternative ways to achieve the same?  Thank you.
I have a script that reads a text stream and generates a file of sed commands that is later run with sed -f. The generated sed commands are like:  s/cid:image002\.gif@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1922/g s/cid:image003\.gif@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1923/g s/cid:image004\.jpg@01CC3D46\.926E77E0/https:\/\/mysite.com\/files\/1924/g   Assume the script which generates the sed commands is something like:  while read cid fileid do     cidpat="$(echo $cid | sed -e s/\\./\\\\./g)"     echo 's/'"$cidpat"'/https:\/\/mysite.com\/files\/'"$fileid"'/g' &gt;&gt; sedscr done   How can I improve the script to ensure all regex metacharacters in the cid string are escaped and interpolated properly?
I see that the code in many packages and examples contains percent signs % at the end of (many) lines. What are they used for? Do they affect the parsing of those lines? How does a sarlacc gain any energy if it keeps victims alive for a thousand years? When eaten by a sarlacc, according to C-3PO,     In his belly, you will find a new definition of pain and suffering, as you are slowly digested over a thousand years.   I imagine that keeping a victim alive for a thousand years takes much more energy than is available to the sarlacc from the body of the victim.  Thus, keeping victims alive for so long would seem to be a net loss of energy for the sarlacc.  Is there a canon answer to resolve this conundrum?  Did the sarlacc have another energy source (for example, ability to harvest sunlight)? What is the greatest integer that divides $p^4-1$ for every prime number $p$ greater than $5$? What is the greatest integer that divides $p^4-1$ for every prime number $p &gt; 5$?  This was on a practice math GRE so it's probably really easy. Apex compile error : variable does not exist I'm having issues with creating a pretty simple test Utility Class. I want to create two records: an account and a related child contact. The error I see in the developer console is:     Variable does not exist: a.ID   My code, based on the Salesforce Apex Workbook, is as follows. I've played around with various things, but it's not working. Where am I going wrong? Thanks in advance.  @isTest public class AccountSaveTestSuite {      public static Account createOneAccount(){           Account testAccount = createAcct('ABC Computing inc.');              Contact testContact = createContact();          return testAccount;             }      // Helper methods //     //        private static Account createAcct(string accountName) {          Account a = new Account(             Name=accountName);         insert a;         return a;     }      private static Contact createContact(){         Contact c = new Contact (             FirstName = 'Jane'              , LastName = 'Smith'             , Account = a.ID); // *** Error is here ***         insert c;         return c;      }  } I am used to see timestamp everywhere by it's color. The recent timestamps are a little bit reddish everywhere. E.g. in Meta Stack Overflow:  Last edit:        Last seen:        But in Meta Stack Exchange they have same color everywhere even for recent time:  Last edit:        Last seen:         Please make it something like this: I want to run DFS replication between a couple of servers. It's my understanding that the servers need to be part of a domain for this. Being able to give people a username and password that works on all servers would be useful too, so I can lock up the admin password.  All machines will be running Windows 2008R2 and they will all be running Windows Firewall, so I need to be able to allow the other machines to connect to this server, but lock out everyone else.   So my question is: what ports do I need to allow the machines to connect to the Domain Controller over? Solving $\sqrt{x+5} = x - 1$ I'm currently learning about radicals and simplifying them, and I came across this problem on the internet and tried to solve it:  $$\sqrt{x+5} = x - 1$$  So I used this logic:  $$ \begin{align} \sqrt{x+5} &amp;= x - 1 \\ x + 5 &amp;= (x-1)^2 \\ x + 5 &amp;= (x-1)(x-1) \\ x + 5 &amp;= x^2 - 2x + 1 \\ 0 &amp;= x^2 - 3x - 4 \\ 0 &amp;= (x-4)(x+1) \\ \end{align} $$  Therefore, $x = -1$ and $x = 4$ satisfy the equation $0 = (x-4)(x+1)$.  But then I tried to plug them in the original problem $\sqrt{x+5}=x-1$:  $$ \begin{align} \sqrt{4 + 5} &amp;= 4 - 1 \\ \sqrt{9} &amp;= 3 \\ 3 &amp;= 3 \end{align} $$  So using 4 works as expected, but when using $-1$:  $$ \begin{align} \sqrt{-1 + 5} &amp;= -1 - 1 \\ \sqrt{4} &amp;= -2 \\ 2 &amp;\ne -2 \end{align} $$  At what stage am I going wrong?  And according the , the solution is $x = 4$. Post Feedback link is broken I first noticed this a while back. But it has yet to resolve itself.  When I click on the  in the 10k tools, it hangs for a while.Then it gives me an error message: Can't connect ad hoc network to Windows 8.1 Pro Prove that $\sum_{n=1}^{\infty}\exp\left(-n^{\varepsilon}\right)$ converges. Using global variables in a function How to recover a dropped stash in Git? I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and review yesterday's stashed changes, but git stash pop appears to remove all references to the associated commit.  I know that if I use git stash then .git/refs/stash contains the reference of the commit used to create the stash. And .git/logs/refs/stash contains the whole stash. But those references are gone after git stash pop. I know that the commit is still in my repository somewhere, but I don't know what it was.  Is there an easy way to recover yesterday's stash commit reference?  Note that this isn't critical for me today because I have daily backups and can go back to yesterday's working tree to get my changes. I'm asking because there must be an easier way! Are there sets $A$ and $B$ such that $A \in B$ and $B \in A$? I think that the question is clear from the title:     Are there sets $A$ and $B$ such that $A \in B$ and $B \in A$?   My feeling is that the definition of any two such sets will be circular (we can't define $B$ till we define $A$ and we can't define $A$ till we define $B$), and hence will be excluded by some axiom.  On the other hand, I can't see an inherent contradiction, though I wouldn't be surprised if some form of Russell's paradox pops up, pushed behind one more set of braces. Display Blank when Referencing Blank Cell in Excel 2010 I have an Excel 2010 workbook that contains a number of individual worksheets. The cells on one of the sheets are linked to individual cells on two other worksheets in the same workbook.  I'm using a direct cell reference that essentially says that whatever value is entered into a particular cell on one sheet also populates cells on two other sheets.  I used the (=) function with the cell reference to accomplish this.  The issue I'm running into is that, even when the primary cell is left blank, the cells that populate from that primary cell will display 0, rather than remaining blank themselves.  I want the subordinate cells to remain blank if the primary cell they're linked to is blank. Convert XML/HTML Entities into Unicode String in Python One post with multiple questions or multiple posts? I want to ask several questions about the same problem domain but each question is independent from the others. Should I put all the questions in a single post or should I split them and send multiple posts? What's the fastest and easiest to read implementation of calculating the sum of digits?  I.e. Given the number: 17463 = 1 + 7 + 4 + 6 + 3 = 21 Why is the derivative of a circle's area its perimeter (and similarly for spheres)? When differentiated with respect to $r$, the derivative of $\pi r^2$ is $2 \pi r$, which is the circumference of a circle.  Similarly, when the formula for a sphere's volume $\frac{4}{3} \pi r^3$ is differentiated with respect to $r$, we get $4 \pi r^2$.  Is this just a coincidence, or is there some deep explanation for why we should expect this? Custom Adapter for List View Overflow: Visible on SVG