What is the best approach to capitalize words in a string?
Is there a simple way to convert a string to Title Case? E.g. john smith becomes John Smith. I'm not looking for something complicated like , just (hopefully) some kind of one- or two-liner.
What is "anycast" and how is it helpful? I'd never heard of anycast until a few seconds ago when I read "".  The wikipedia "" article on it is quite formal and doesn't really evoke a mental picture of how it would be used.  Can someone explain in a few informal sentences what "anycast" is, how you configure it (just in a general sense), and what its benefits are (what does it make easier)? Multiple domains for different products? I have a website with software applications. Is it good for SEO to choose one keyword rich domain name for each of our software products or should we stick to a single domain?  From a user's perspective I think it would be easier to remember a domain that is keyword rich as the user will instantly know what this product is for.  But I have read articles that the latest trend in SEO is to stick to one domain for all of your products and invest on this single domain website.  Is that true? What do you advise? Should I register a separate domain for each of our products or should I use only one single domain?  Should I do a 301 redirect with a .htaccess to a single domain? And what about the sitemaps? Should I register all sites in Google Webmaster Tools and post a separate sitemap for each one of them? should my main site sitemap include all pages or should separate domains have their own sitemaps? How do you return from 'gf' in Vim I am using Vim for windows installed in Unix mode. Thanks to this site I now use the gf command to go to a file under the cursor.  I'm looking for a command to either:   return to the previous file (similar to Ctrl+T for ctags), or   remap gf to automatically launch the new file in a new window. Clever bounty reputation hack I say "hack" in the most favorable light. It's a clever idea and theoretically beneficial.  I noticed that an old question of mine suddenly started getting a lot of renewed attention. The question had been answered, with an answer accepted. But another user added a well reasoned and insightful answer to the list. He also opened a +100 bounty on that question.  The resulting increased attention quickly got his answer quite a lot of up-votes. Well more than the 100 points he had spent on the bounty. Therefore, he gets a net rep profit out of the transaction.  So here's the hack:   Find an interesting question Research and provide a very good answer Open up a bounty on that question to attract attention and votes to your new answer Profit!!!   2 and 3 may be out of order--I didn't see the timing of it. But either way, assuming he gets more than 10 votes, he still gets increased rep out of the deal.  I don't think this is necessarily bad for SO - it does generate some useful discussion and insightful answers. Plus you can increase your own rep very rapidly by making your answers highly visible, and therefore frequently voted upon.   However, it does slightly change the meaning and purpose of bounties away from starting a discussion and toward self-promotion. Still, interesting. How to show this equality of $\rho(X,Y)$ Let I have $(S,\Sigma,\mu)$ be a probability space, then $X,Y \in \Sigma$. Define $\rho (X,Y)$ by $\rho (X,Y)$ = correlation between random variable $I_X$ and $I_Y$, where $I_X$ and $I_Y$ are the indicator function of $X$ and $Y$. Express $\rho (X,Y)$ in term of $\mu (X)$, $\mu (Y)$, $\mu(XY)$. Conclude that $\rho(X,Y)=0$, if and only if $X$ and $Y$ are independent.      How to show that: $$\rho(X,Y)= \frac{\mu(XY)\,\mu(X^cY^c)-\mu(XY^c)\,\mu(X^cY)}{(\mu(X) \,\mu(X^c)-\mu(Y) \,\mu(Y^c))^{1/2}};0&lt;\mu(X)&lt;1;\,0&lt;\mu(Y)&lt;1$$ Initialize class fields in constructor or at declaration? I've been programming in C# and Java recently and I am curious where the best place is to initialize my class fields.  Should I do it at declaration?:  public class Dice {     private int topFace = 1;     private Random myRand = new Random();      public void Roll()     {        // ......     } }   or in a constructor?:  public class Dice {     private int topFace;     private Random myRand;      public Dice()     {         topFace = 1;         myRand = new Random();     }      public void Roll()     {         // .....     } }   I'm really curious what some of you veterans think is the best practice. I want to be consistent and stick to one approach. I am able to successfully use wp.hooks.applyFilters() and wp.hooks.addFilter(), but I'm not able to render a React Component using wp.hooks.addAction(). However, the console.log() runs just fine within the callback for an action. This is my code:  import { createHooks } from '@wordpress/hooks';  let globalHooks = createHooks();  const Header = () =&gt; {     return (         &lt;h1&gt;Header Component&lt;/h1&gt;     ); }  const RevisedHeader = () =&gt; {     return (         &lt;h1&gt;Revised Header Component&lt;/h1&gt;     ) }  export default class App extends Component {      constructor( props ) {         super();          globalHooks.addFilter( 'replace_header', 'revisedHeaderCallback', this.revisedHeaderCallback );         globalHooks.addAction( 'after_replace_header', 'afterRevisedHeaderCallback', this.afterRevisedHeaderCallback );     };      revisedHeaderCallback( header ) {         return &lt;RevisedHeader /&gt;;     }      afterRevisedHeaderCallback() {         return &lt;RevisedHeader /&gt;;     }      render() {          return(             &lt;div className="App"&gt;                 { globalHooks.applyFilters( 'replace_header', &lt;Header /&gt; ) }                 { globalHooks.doAction( 'after_replace_header' ) }             &lt;/div&gt;         );     } } I read recently that you can find the number of digits in a number through the formula $\lfloor \log_{10} n \rfloor +1$ What's the logic behind this rather what's the proof? Why is moving directories to /dev/null dangerous? I'm flying Etihad Airways to Melbourne and I've a 14 hours layover at Abu Dhabi.  Some say that as long as you are inside the airport terminal you don't require a transit visa while some say you need a transit visa if your layover is more than 10 hours.  Can I stay inside the airport without a transit visa? I know how to define a package or a class, but how do I make it available (to myself) at all times?  Say I have the package file commonstuff.sty (or myprettyclass.cls), that I want to be able to include in any .tex file I create on my computer. Where do I put it? Do I need to run some installer on it, or is it enough to keep it in a certain folder?  Note: I know I can just place it in the same folder as the .tex file, but that's not what I'm after here. I'm looking for a way to "install" the package centrally on my computer. How is ISO implemented in digital cameras? If I change the ISO settings on my camera, obviously the gain of the system is increased, amplifying the signal from the sensor. What's not clear to me is where the amplification takes place. I see several possibilities:   In the sensor, by increasing voltage or some other mechanism Via an analog amplifier outside of the sensor Digitally, after the signal has been digitized, but before storing data in the RAW file As a parameter applied solely in creating an image from RAW   If #4 is true, then you could take a 4-stop overexposed RAW picture at ISO 1600, and then in post processing produce a JPEG at ISO 100 that would be the same as if the original photo had been shot at ISO 100.  If #1 or #2 is true, then a RAW file shot at ISO 1600 would actually contain more information about shadows, and an ISO 100 RAW would contain more information about highlights. Can I add extension methods to an existing static class? I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static class, such as Console.  For example, if I want to add an extension to Console, called 'WriteBlueLine', so that I can go:  Console.WriteBlueLine("This text is blue");   I tried this by adding a local, public static method, with Console as a 'this' parameter... but no dice!      public static class Helpers {     public static void WriteBlueLine(this Console c, string text)     {         Console.ForegroundColor = ConsoleColor.Blue;         Console.WriteLine(text);         Console.ResetColor();     } }   This didn't add a 'WriteBlueLine' method to Console... am I doing it wrong? Or asking for the impossible? What is momentum really? Would you take a share in Stack Overflow? Joel Spolsky has just posted  where he talks about seeking venture capital for Stack Overflow.  If instead they opted to seek shareholders from the StackOverflow community along the lines of the , but at a larger scale, would you be interested?  I'm asking this because I suspect there might be enough fanatics willing to invest $500 or so in a product they love to raise a considerable sum. People also often talk about the motivation for high rep users. It seems to me having an actual stake in the product might be a decent incentive (especially if you also get a gold badge for buying shares). How can I maximize the "blurry background, sharp subject" (bokeh) effect? The equivalence of open-set definition of continuous mappings to the $\epsilon-\delta$ definition A function $f: M\rightarrow N$ is defined to be continuous iff $\forall$ open set $U\subseteq N$, the preimage of $U$ is also open.  I was trying to prove that such a definition would be equivalent to the $\epsilon -\delta$ definition in a metric space, and I could only do so if I assume $f$ is surjective, or otherwise a counterexample would be $g: \mathbb{R}\rightarrow\mathbb{R}$ where $g(x)=x^2$. As if I take $U=(-1,1)$, then its preimage is $[0,1)$, which is neither open or closed. In fact, any $U$ containing elements that cannot be achieved by $g$ would face the same problem.  So I was wondering that have I remembered the definition of preimage wrong, or do I need to make sure that $U$ must be chosen from the image set of $f$? options for [for /f "usebackq" %%f in (`find "" path`) do] sentence in batch I symplified my problem: @echo off set res=  for /f &quot;usebackq&quot; %%f in (`find &quot;a&quot; list.txt`) do set res=%%f echo %res%  pause&gt;nul and that things.txt file in the code is like:  list.txt file in the code is: apple pitch pear melon mango  As you expect, the result of this code is mango  because the line 'mango' is located below the line 'apple' and 'pear' But the result I want is apple  or pear  Specifically, I want to put each of the other values above mango such as apple and pear into the variable res using option keys provided. is there any way to do that? Why shift-cmd-n fails as a custom shortcut for Firefox "New Private Window"? I created the shiftcommandn shortcut for Firefox in Syst Prefs to match other browsers' behavior.     It registers in the Firefox Menubar.     But pressing the shortcut opens a new non-private window, and it loads there the first item in my "Top Sites".   I imagine I could create another shortcut to override this behavior, but what is this behavior? I don't see anything highlighted in the Firefox Menubar when I hit the shortcut. Or might there be another solution (other than using a different shortcut to open new private windows)?   Problem exists on both Mojave and High Sierra. Default Firefox shortcut (shiftcommandp) still opens a new private window. I am currently in need of using apt-get on a chroot directory. The setup is the following.  I have a chroot setup with schroot. This chroot environment needs to be stripped down as much as possible. Therefore I am planning to remove apt-get and commin from the chroot environment.  I know that Gentoo has the possibility to use portage on a different root directory. Is this possible to set a different root directory for apt.get to install software into my chroot directory?  Thanks in advance