I am developing web application using C#. I want to replace multiple character in a string. For example,  string str = "abc_def|ghij_klmn:opq|rst:uv_wx|yz"; str = str.Replace("_","-"); str = str.Replace("|",", "); str = str.Replace(":",". ");   OR  string str = "abc_def|ghij_klmn:opq|rst:uv_wx|yz"; str = str.Replace("_","-").Replace("|",", ").Replace(":",". ");   The above are the sample coding, actually I want to replace more characters. Is there any performance related issue in above two codes?  This may be a duplicate question, I searched for that, but I didn't find...  Thanks
string str1 = "12345ABC...\\...ABC100000";   // Hypothetically huge string of 100000 + Unicode Chars  str1 = str1.Replace("1", string.Empty);  str1 = str1.Replace("22", string.Empty);  str1 = str1.Replace("656", string.Empty);  str1 = str1.Replace("77ABC", string.Empty);   // ...  this replace anti-pattern might happen with upto 50 consecutive lines of code.   str1 = str1.Replace("ABCDEFGHIJD", string.Empty);   I have inherited some code that does the same as the snippet above. It takes a huge string and replaces (removes) constant smaller strings from the large string.  I believe this is a very memory intensive process given that new large immutable strings are being allocated in memory for each replace, awaiting death via the GC.  1. What is the fastest way of replacing these values, ignoring memory concerns?  2. What is the most memory efficient way of achieving the same result?  I am hoping that these are the same answer!  Practical solutions that fit somewhere in between these goals are also appreciated.  Assumptions:    All replacements are constant and known in advance Underlying characters do contain some unicode [non-ascii] chars
When I click the bounty info icon on the iOS app. The added bounty description and reason is not shown.  For example: Why are Python's 'private' methods not actually private? Hyphen or no hyphen when modifying an adjective with a quantity? Possible Duplicate:           What book would you recommend for an undergraduate wanting to learn the basics of topology? I've come across several books that claim to give an introduction to the subject, but I wasn't sure which one(s) to pick.  Here are some of the books I came across:   Introduction to Topology - Bert Mendelson Basic Topology - M.A. Armstrong First Concepts of Topology - William G. Chinn Topology Without Tears - Sidney A. Morris Topology - James Munkres   They don't go over the exact same topics, some are more in-depth than others, some seem to target slightly different audiences etc. What would be right for me (not necessarily from that list)? To give some more background, I want to learn topology because I feel it will be somewhat helpful in the field of Computer Vision. How can I chroot sftp-only SSH users into their homes? I want to give a client access to my server, but I want to limit those users to their home directories. I will bind-mount in any files I want them to be able to see.  I've created a user called bob and added him to a new group called sftponly. They have a home directory at /home/bob. I've changed their shell to /bin/false to stop SSH logins. Here is their /etc/passwd line:  bob:x:1001:1002::/home/bob:/bin/false   I've also changed the /etc/ssh/sshd_config to include the following:  Match Group sftponly         ChrootDirectory /home/%u         ForceCommand internal-sftp         AllowTcpForwarding no   When I try to log in as them, here's what I see   $ sftp bob@server bob@server's password:  Write failed: Broken pipe Couldn't read packet: Connection reset by peer   If I comment out the ChrootDirectory line I can SFTP in but then they have free rein over the server. I have found that ChrootDirectory /home works, but it still gives them access to any home directory. I have explicitly tried ChrootDirectory /home/bob but that doesn't work either.  What am I doing wrong? How can I limit bob to /home/bob/?  ----EDIT-----  Okay so I just had a look at /var/log/auth.log and saw this:  May  9 14:45:48 nj sshd[5074]: pam_unix(sshd:session): session opened for user bob by (uid=0) May  9 14:45:48 nj sshd[5091]: fatal: bad ownership or modes for chroot directory component "/home/bob/" May  9 14:45:48 nj sshd[5074]: pam_unix(sshd:session): session closed for user bob   I'm not entirely sure what's going on there,  but it suggests something is wrong with the user directory. Here is the ls -h /home output:  drwxr-xr-x 26 oli      oli      4096 2012-01-19 17:19 oli drwxr-xr-x  3 bob      bob      4096 2012-05-09 14:11 bob Existence of minimal prime ideal contained in given prime ideal and containing a given subset Let $R$ be a unital commutative ring, $P$ $\subseteq$ $R$ a prime ideal, $X\subseteq P$ a subset. Show there exists a minimal (inclusion minimal) prime ideal contained in $P$ which contains $X$.   My approach: Let $\langle X\rangle$ be the ideal generated by $X$. $P^c$ is a multiplicative set, as $P$ is prime. $\langle X\rangle\subseteq P\subseteq R$ and $P^c\cap\langle X\rangle=\emptyset $ so by Zorn's lemma there exist prime ideal $I_1$ satisfying $\langle X\rangle\subseteq I_1\subseteq P$. As $I_1$ is prime, it's complement is a multiplicative subset which does not intersect $\langle X\rangle$, hence I can find prime ideal $I_2$ satisfying $\langle X\rangle\subseteq I_2 \subseteq I_1$ and so on... I've got an infinite descending chain of prime ideals and I can't be sure that the process will stop.  Hints will be appreciated, thank you.   Edit: Can I conclude that every prime ideal contains a minimal prime ideal? How to automount NTFS partitions? I have two NTFS partitions, and I don't want to mount them manually every-time I start Ubuntu.   How can I do this?  Is there a tool or a code to use?   If so, is it safe to automount? specially when they are being used by another OS? How to delay a command block I have created a short command block stack, one block teleports the player and the other plays block.piston.extend. My problem is that it teleports the player before the player can hear the sound. I would like to know if there is a way to delay the command from inside that command block. I have looked at other solutions but they all involve some complex scoreboard timer thing. If you could give me a solution that doesn't use that system or maybe you could explain it better.  This is the command I need to delay:  /tp @p -586.634 64 -430.697   If anyone could help I would really appreciate it, so thanks in advance! Simple georeferenced 3D data format for building models Include some chat capabilities in iOS app Currently, the app notifies users when they're mentioned in chat. However, when we tap on the notification, we got redirected out of the app to Safari.   Is there a chance we can get some chat capabilities in the app, so that we don't have to login again in Safari to quickly reply to the messages?    App version: 0.1.19 09/19/2014 Transfer Clash of Clans account from one G+ to another G+ account? Let $H$ be a subgroup of $G$ with $[G:H]=n$. Let $N$ be the kernel of the left-multiplication action on the cosets of $H$. Show $[G:N]$ divides $n!$ Let $H$ be a subgroup of $G$ with $[G:H]=n$ and $G$ finite.  Let $G$ act on left cosets of $H$ by left multiplication.  Let $N$ be the kernel of the action.  Show that $[G:N]$ divides $n!$.  Ok so I have a theorem that says that if $G$ is simple then it embeds into $S_n$.  So if $G$ is simple than I'm done because $G$ divides $n!$ and thus $N$ divides $n!$ and hence $[G:N]$ divides $n!$.  Now I also know that $N$ is the largest normal subgroup of $G$ contained in $H$.  Thus if $G$ isn't simple then it contains some non-trivial normal subgroup $K$ and thus $K\cap H$ is normal in $H$ and by the 2nd Iso Theorem $H/K\cap H\cong KH/H$...    As you can see I'm not sure where to go from here. I was hoping to prove that $K\cap H$ wasn't trivial and thus that $N$ couldn't be trivial since it must contain $K\cap H$, but I'm not sure I can, and even if I could I'm not sure that would help me in showing that $[G:N]$ is small enough to divide $n!$.  Can anyone give some guidance?  Thanks. I think this was more of a fantasy series, though it was more subtle than The Lord of the Rings IIRC. Set in modern times - though there was some alternate realm thing that was less modern I think.   I read it about ten years ago, I think, and there were a number of books at that time. My brother and I stopped reading it shortly after the main character summoned a small demon somehow who was a bad influence... I think.  It involved a boy who somehow was at some kind of training school/academy. Unsure where it was located, but it needed a classic portal to get to it I think. I clearly remember some scene involving a car driving at specific speeds to get past some barriers. There may have been something about how the school was (slowly) moving or the wards were shrinking... unsure. I don't think it was only magic based, but that was some element of it. The boy had some kind of strange power that made him an incredible fighter, but he wasn't sure how (at least from what I remember). The recordings of him training just showed a white flash I think. I remember some scene in an elevator going down to the training floor where he went to a level below some adult with him.  There was something else about him joining a group that had twelve members, one for each month, whose powers grew and lessened based on how close the date was to "their" month.  Oh, and there was something about him looking for his mother I think? Perhaps in another "realm"?   Any help is appreciated! Location of parenthesis for auto-executing anonymous JavaScript functions? Today I taught an introductory class of statistics and a student came up to me with a question, which I rephrase here as: "Why is the standard deviation defined as sqrt of variance and not as the sqrt of sum of squares over N?"  We define population variance: $\sigma^2=\frac{1}{N}\sum{(x_i-\mu)^2}$   And standard deviation: $\sigma=\sqrt{\sigma^2}=\frac{1}{\sqrt{N}}\sqrt{\sum{(x_i-\mu)^2}}$.   The interpretation we may give to $\sigma$ is that it gives the average deviation of units in the population from the population mean of $X$.   However, in the definition of the s.d. we divide the sqrt of the sum of squares through $\sqrt{N}$. The question the student raises is why we do not divide the sqrt of the sume of squares by $N$ instead. Thus we come to competing formula: $$\sigma_{new}=\frac{1}{N}\sqrt{\sum{(x_i-\mu)^2}}.$$ The student argued that this formula looks more like an "average" deviation from the mean than when dividing through $\sqrt{N}$ as in $\sigma$.  I thought this question is not stupid. I would like to give an answer to the student that goes further than saying that the s.d. is defined as sqrt of the variance which is the average squared deviaton. Put differently, why should the student use the correct formula and not follow her idea?  This question relates to an older thread and answers provided . Answers there go in three directions:   $\sigma$ is the root-mean-squared (RMS) deviation, not the "typical" deviation from the mean (i.e., $\sigma_{new}$). Thus, it is defined differently. It has nice mathematical properties. Furthermore, the sqrt would bring back "units" to their original scale. However, this would also be the case for $\sigma_{new}$, which divides by $N$ instead.   Both of points 1 and 2 are arguments in favour of the s.d. as RMS, but I do not see an argument against the use of $\sigma_{new}$. What would be the good arguments to convince introductory level students of the use of the average RMS distance $\sigma$ from the mean? I am working on a print for my wall and I am trying to create something like this:      I have already created the letters in Illustrator and now I am adding the colors in Illustrator and then exporting everything to Photoshop and then using the liquify tool to blend the colors to create a similar effect. I also used the healing patch tool to blend in the hard edges.  Is that the right way of doing it? Or is there another way? What is the reason that the value "47" is so popular in electrical engineering? How does ServerName and ServerAlias work? It's the following part of a virtual host config that I need further clarification on:  &lt;VirtualHost *:80&gt;   # Admin email, Server Name (domain name), and any aliases   ServerAdmin example@example.com   ServerName  141.29.495.999   ServerAlias example.com ...   This is and example config, similar to what I currently have (I don't have a domain name at the moment).  &lt;VirtualHost *:80&gt; - Allow the following settings for all HTTP requests made on port 80 to IPs that this server can be contacted on. For instance, if the server could be accessed on more than one IP, you could restrict this directive to just one instead of both.  ServerName - If the host part of the HTTP request matches this name, then allow the request. Normally this would be a domain name that maps to an IP, but in this case the HTTP request host must match this IP.  ServerAlias - Alternate names accepted by the server.  The confusing part for me is, in the above scenario, if I set ServerAlias mytestname.com and then made an HTTP request to mytestname.com, there would have to be a DNS record pointing to the server's IP for this to work? In which case, is ServerAlias just basically EXTRA ServerName entries?  Say I had a DNS entry such that foobar.com = 141.29.495.999 but then I had ServerName = 141.29.495.999 and ServerAlias was empty, would that mean that although foobar.com gets resolved to the right IP, because there is no reference to accept foobar.com in ServerName or ServerAlias?  Or something. Man I'm confused. Using OpenSUSE leap 15.1 10.2.29-lp151.2.9.1-x86_64 from vendor OpenSUSE (installed)  CREATE TABLE testtab2(     my_id2 INT AUTO_INCREMENT,     name2 VARCHAR(10),     comment2 VARCHAR(20),     PRIMARY KEY (my_id2) );   testtab.txt:  |Roger |hurray   | |George|today    | |Paul  |yesterday| |John  |last year| |Ringo |tomorrow |   LOAD DATA LOCAL INFILE 'testtab.txt' INTO TABLE testtab FIELDS TERMINATED BY '|';   works fine with linenumbers (my_id) 1-5  INSERT INTO testtab (name,comment) VALUES ('Beatles','band');   this gets linenumber (my_id) 8 - should be 6.  If testtab.txt have 8 records and using INSERT INTO 1 record this gets linenr (my_id) 16. This happens in other tables too - one moved from 199 to 256.  Anyone who can solve the problem? Analyzing a sentence Do my analyze is correct? If don't then correct it.  Sentence: The tsunami and the undersea earthquake which triggered it, the largest ever recorded in the region, killed nearly 20,000 people, destroyed over 100,000 homes and threw the lives of tens of millions into turmoil.  Subject: The tsunami and the undersea earthquake Principal verb: triggered Adjective clause of subject:the largest ever recorded in the region, killed nearly 20,000 people, destroyed over 100,000 homes Use of parallelism:threw the lives of tens of millions into turmoil.