How can I make a function that splits a multiline string every nth character. I have the below function, but it doesn't work correctly with multiline strings. splitIntoChunks(&quot;abab&quot;, 2) works correctly and gives [&quot;ab&quot;, &quot;ab&quot;] But, this doesn't work correctly: var str = `aaa bbb ccc ddd`  splitIntoChunks(str, 2)  This returns [&quot;aa&quot;, &quot;a&quot;, &quot;bb&quot;, &quot;b&quot;, &quot;cc&quot;, &quot;c&quot;, &quot;dd&quot;, &quot;d&quot;] And what I need is: [&quot;aa&quot; [&quot;a\n&quot;, &quot;bb&quot;, &quot;b\n&quot;, &quot;cc&quot;, &quot;c\n&quot;, &quot;dd&quot;, &quot;d\n&quot;]] It needs to keep the \n function splitIntoChunks(str, size) {   return str.match(new RegExp('.{1,' + size + '}', 'g')); }
For example, this regex  (.*)&lt;FooBar&gt;   will match:  abcde&lt;FooBar&gt;   But how do I get it to match across multiple lines?  abcde fghij&lt;FooBar&gt;
Man/Tree Symbiosis It was an old book... I'm pretty sure it was a book, and pre-1990's I think. The basic plot was this man somehow interacted with this tree, and as a result he became a carrier of the tree's 'seed'. They were in a symbiotic relationship: the man got a much longer life, more strength, etc.; but when he did die the tree would grow up from his body. When a player joins the server, this command block (containing gamemode 2 @a) puts them into gamemode 2/adventure mode. How can I change this so that only non-admin/not "opped" players' gamemode gets changed? Our high-school teacher told us that the Earth pulls us with some force $F$ and we pull the Earth with the same force $F$. Within Newtonian physics this is true because of , but let’s consider . My mass is small; so I don’t warp space-time much. But Earth’s large mass warps space-time to a far greater extent.  So do I pull Earth with the same force it pulls me? If yes, how? How to enable linking floating point library in TurboC? Solve $\sum nx^n$ I am trying to find a closed form solution for $\sum_{n\ge0} nx^n\text{, where }\lvert x \rvert&lt;1$.  This solution makes sense to me:  $\sum_{n\ge0} x^n=(1-x)^{-1} \\ \frac{d}{d x} \sum_{n\ge0} x^n = \frac{d}{d x} (1-x)^{-1} \\ \sum_{n\ge0} nx^{n-1} = (1-x)^{-2} \\ x \sum_{n\ge0} n x^{n-1} = x(1-x)^{-2} \\ \sum_{n\ge0} nx^n=\frac x{(1-x)^2}$  However, a  I am reading used the following method:  $$\sum_{n\ge0}nx^n=\sum_{n\ge0}x\frac d{dx}x^n= x\frac d{dx}\sum\limits_{n\ge0}x^n=x\frac d{dx}\frac1{1-x}=\frac x{(1-x)^2}$$  This seems closely related to the solution I described above, but I am having difficulty understanding it.  Can someone explain the method being used here? I wonder about the Adjustments to Cost Basis after a wash sale occur. Considering this  ( from marketwatch.com) where someone: On 1 Dec, 2018 used an amount of money in his account to buy 100 shares of XYZ Co., for $2000 (to make it simple , let's say 1 Feb, 2019 to turn all the transactions into the same year) On 1 Apr, 2019 he sells the shares for $1200, and incurred a loss of 800$. On 10 Apr, 2019 he bought back 100 shares for $1300, and had a wash sale. The 800$ loss gets added to the cost basis of this transaction( and the basis becomes $2100) Now, If on 13 Apr 2019, he sold 100 shares for $1400; I'm pretty sure that the realized Gain/Loss record of this transaction would show something like this: &quot; XYZ Co. shares  100 , Proceeds $1400 , Cost basis  $2100(adjusted), Short-term Gain/Loss  -$700 &quot;. So, even though the Gain/Loss shows a negative number, he still got an actual profit of $100 from this sale, right? What is the progression route in Terraria? I've seen many boads with weird zig-zag shaped tracks just like the one below. Why are they designed like that? Why do we need autoencoders? Recently, I have been studying autoencoders. If I understood correctly, an autoencoder is a neural network where the input layer is identical to the output layer. So, the neural network tries to predict the output using the input as golden standard.  What is the usefulness of this model? What are the benefits of trying to reconstruct some output elements, making them as equal as possible to the input elements? Why should one use all this machinery to get to the same starting point? How to test multiple variables against a single value? I am trying to determine what issues could be caused by using the following serialization surrogate to enable serialization of anonymous functions/delegate/lambdas.   // see http://msdn.microsoft.com/msdnmag/issues/02/09/net/#S3 class NonSerializableSurrogate : ISerializationSurrogate {     public void GetObjectData(object obj, SerializationInfo info, StreamingContext context)     {         foreach (FieldInfo f in obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))             info.AddValue(f.Name, f.GetValue(obj));     }      public object SetObjectData(object obj, SerializationInfo info, StreamingContext context,                                 ISurrogateSelector selector)     {         foreach (FieldInfo f in obj.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic))             f.SetValue(obj, info.GetValue(f.Name, f.FieldType));         return obj;     } }     Listing 1 adapted from   The main issue I can think of that might be a problem is that the anonymous class is an internal compiler detail and it's structure is not guaranteed to remain constant between revisions to the .NET Framework. I'm fairly certain this is the case based on my research into the similar problem with iterators.  Background  I am investigating the serialization of anonymous functions. I was expecting this not to work, but found it did for some cases. As long as the lambda did *not&amp; force the compiler to generate an anonymous class everything works fine.   A SerializationException is thrown if the compiler requires a generated class to implement the anonymous function. This is because the compiler generated class is not marked as serializable.  Example  namespace Example {     [Serializable]     class Other     {         public int Value;     }      [Serializable]     class Program     {         static void Main(string[] args)         {             MemoryStream m = new MemoryStream();             BinaryFormatter f = new BinaryFormatter();              // Example 1             Func&lt;int&gt; succeeds = () =&gt; 5;             f.Serialize(m, succeeds);              // Example 2             Other o = new Other();             Func&lt;int&gt; fails = () =&gt; o.Value;             f.Serialize(m, fails); // throws SerializationException - Type 'Example.Program+&lt;&gt;c__DisplayClass3' in Assembly 'Example, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.         }     }   Listing 2  This is similar to the issue of trying to serialize iterators and I had found the following code in a previous search (see ) Using the code from Listing 1 and an ISurrogateSelector I was able to successfully serialize and deserialize the second failing example.  Objective  I have a system that is exposed via a web service. The system has a complex but small state (many objects, not a lot of properties per object). The state is saved in the ASP.NET Cache, but is also serialized to a BLOB in SQL in case of cache expiration. Some objects need to execute arbitrary "events" upon reaching some condition. Hence they have properties accepting Action/Func objects. Contrived example:      class Command     {         public Command(Action action, Func&lt;bool&gt; condition);     }   Somewhere else      void DoSomethingWithThing(Thing thing)     {         state = Store.GetCurrentState();          Command cmd = new Command(() =&gt; thing.Foo(), () =&gt; thing.IsReady())         state.Add(cmd);          Store.Save(state);     } Cannot favorite once up voted I'm not sure whether this is exactly the same bug as  or whether this is a new bug.  If you up vote a question and then attempt to add it to favorites too you get Question is already favorited:    This also happens if you up vote on the web site and then try to favorite it from Android. If you don't up vote or if you favorite it first and then up vote it appears to work fine. I have a number of measurements of the same quantity (in this case, the speed of sound in a material). Each of these measurements has their own uncertainty.  $$ v_{1} \pm \Delta v_{1} $$ $$ v_{2} \pm \Delta v_{2} $$ $$ v_{3} \pm \Delta v_{3} $$ $$ \vdots $$ $$ v_{N} \pm \Delta v_{N} $$  Since they're measurements of the same quantity, all the values of $v$ are roughly equal. I can, of course, calculate the mean:  $$ v = \frac{\sum_{i=1}^N v_{i}}{N}$$  What would the uncertainty in $v$ be? In the limit that all the $\Delta v_i$ are small, then $\Delta v$ should be the standard deviation of the $v_i$. If the $\Delta v_i$ are large, then $\Delta v$ should be something like $\sqrt{\frac{\sum_i \Delta v_i^2}{N}}$, right?  So what is the formula for combining these uncertainties? I don't think it's the one given in  (though I may be wrong) because it doesn't look like it behaves like I'd expect in the above limits (specifically, if the $\Delta v_i$ are zero then that formula gives $\Delta v = 0$, not the standard deviation of the $v_i$). Previous question:    That was when my buttons died.  On other days, my text dies.    And some times it's just italics.    Now, I like blaming @skiwi for this, and he's often nearby when it happens.  But today, he's not here, and it happened again.    I'm running Windows 8 and using Chrome 40.0.2214.94 m.  Refreshing and such does not fix the issue.  Inspect element -> console -> error log:  http://chat.stackexchange.com/chats/8595/messages/new Failed to load resource: the server responded with a status of 409 (Conflict) http://i.stack.imgur.com/2ZJdJ.png?s=128&amp;g=1&amp;g&amp;s=16 Failed to load resource: the server responded with a status of 502 (Bad Gateway) http://i.stack.imgur.com/boUZp.jpg?g&amp;s=16 Failed to load resource: the server responded with a status of 502 (Bad Gateway) http://i.stack.imgur.com/U8P3C.jpg?s=128&amp;g=1&amp;g&amp;s=32 Failed to load resource: the server responded with a status of 502 (Bad Gateway) http://i.stack.imgur.com/boUZp.jpg?g&amp;s=16 Failed to load resource: the server responded with a status of 504 (Gateway Time-out) http://chat.stackexchange.com/messages/19891816 Failed to load resource: the server responded with a status of 409 (Conflict)   What's going on here?  I should note, I can view italics by selecting, then alt-tabbing:    So it reeks of a client-side issue. What's hiding the text from me?  EDIT:  30 april 2015 it happened again =/ Is "princessship" a real word? Are there any other words which have the same letter 3 times consecutively? How to achieve nomenclature entries like: symbol, Description, Dimension and unit, etc? The title is pretty much I want to ask. More detail, the nomenclature entries should be sorted in groups like:   Nomenclature     Acronyms     Symbol  Description     % no Dimensions and Units      ...     Greek Symbols     Symbol  Description             Dimensions     Units     ...     Roman Symbols     Symbol  Description             Dimensions     Units     S       Surface area vector     L^2            m^2     ...    Superscripts     Symbol  Description     % no Dimensions and Units      ...    Dimensionless Numbers     Symbol  Description     Definition     ...   e.g. expected entries like this:       My current nomenclature settings for grouping [book class]:  %---------------------------------------------------------- %                        Nomenclature %---------------------------------------------------------- %\renewcommand{\nomname}{List of Symbols and Abbrev.} \renewcommand\nomgroup[1]{%   \ifthenelse{\equal{#1}{A}}{%    \item[\textbf{Acronyms}] }{%                  A - Acronyms     \ifthenelse{\equal{#1}{R}}{%      \item[\textbf{Roman Symbols}]}{%            R - Roman       \ifthenelse{\equal{#1}{G}}{%         \item[\textbf{•} Symbols }]}{%          G - Greek           \ifthenelse{\equal{#1}{S}}{%            \item[\textbf{Superscripts  }]}{{%          S - Superscripts         \ifthenelse{\equal{#1}{U}}{%          \item[\textbf{Subscripts }]}{{%                 U - Subscripts         \ifthenelse{\equal{#1}{X}}{%          \item[\textbf{Other Symbols }]}%            X - Other Symbols                     {{}}}}}}}}}} %\ifpdf \renewcommand{\nomlabel}[1]{\hspace{1 em}#1}%{\hspace{1.5 em}#1} \renewcommand*{\nompreamble}{\markboth{\nomname}{\nomname}}   But how to extend it with Dimensions and Units? How to create 2D shadows I'd like to create lights and shadows in a 2D environment, like in the image below:    I did several searches but got no results. Do you have any hint? Java Server Socket not connecting Let $\Omega$ be a region in the complex plane and let $f_1$ and $f_2$ be holomorphic functions on $\Omega$ having no common zero. Show that there exist holomorphic functions $g_1$ and $g_2$ on $\Omega$ such that, $f_1g_1+f_2g_2$ is identically equal to one on $\Omega$. Seeking alternatives to pgRouting for open source routing / network analysis?