here's my bbcode parser class :    &lt;?php class BBCode {       public function __construct(){}      private function showBBcodes($text) {           $text = htmlspecialchars($text); //skip HTML          preg_match_all('#\[code\](.*?)\[/code]#is', $text, $stack);          // BBcode array         $find = array(             '~\[b\](.*?)\[/b\]~s',             '~\[i\](.*?)\[/i\]~s',             '~\[quote\](.*?)\[/quote\]~s',             //'~\[code\](.*?)\[/code\]~s'         );          // HTML tags to replace BBcode         $replace = array(             '&lt;b&gt;$1&lt;/b&gt;',             '&lt;i&gt;$1&lt;/i&gt;',             '&lt;/p&gt;&lt;blockquote&gt;$1&lt;/blockquote&gt;&lt;/p&gt;',             //'&lt;div class="code_box"&gt;$1&lt;/div&gt;'         );                     $text = nl2br(preg_replace($find,$replace,$text));          foreach($stack[1] as $t) {            $text = preg_replace('#\[code\].*?\[/code]#is', $t, $text,1);           }          return $text;     }             // Smiley to image     private function parseSmiley($text){         // Smiley to image         $smileys = array(             ':wave:' =&gt; 'wave.gif',             ':hahaha:' =&gt; 'hahaha.gif',             ':help:' =&gt; 'help.gif'         );         // Now you need find and replace         foreach($smileys as $smiley =&gt; $img){             $text = str_replace(                     $smiley,                 "&lt;img src='images/smiley/{$img}' alt='{$smiley}'/&gt;",                 $text             );         }         // Now only return it         return $text;         }           public function parser($message){         $parser_content = $message;         $parser_content = $this-&gt;showBBcodes($parser_content);         $parser_content = $this-&gt;parseSmiley($parser_content);         return $parser_content;     }  }   this class can BBcode parse &amp; Smiley to image &amp; auto link.  but, I have some question and I can't fix it.   if active Line 16 and 25  //'~\[code\](.*?)\[/code\]~s' //'&lt;div class="code_box"&gt;$1&lt;/div&gt;'    will be parser [code] [b]text[/b] [/code]  tag content to storng   if not active  Line 31 and 54....  I can't styling its CSS Now existing code just can noparse BBcode (can't skip smily code), everybody can suggest more smart code to skip all content...  ?
I'd like to work on a bbcode filter for a php website. (I'm using cakephp, it would be a bbcode helper) I have some requirement.    Bbcodes can be nested. So something like that is valid.  [block]       [block]       [/block]       [block]           [block]           [/block]       [/block]   [/block]     Bbcodes can have 0 or more parameters.     Exemple:     [video: url="url", width="500", height="500"]Title[/video]   Bbcodes might have mutliple behaviours.     Let say, [url]text[/url] would be transformed to [url:url="text"]text[/url] or the video bbcode would be able to choose between youtube, dailymotion....  I think it cover most of my needs. I alreay done something with regex. But my biggest problem was to match parameters. In fact, I got nested bbcode to work and bbcode with 0 parameters. But when I added a regex match for parameters it didn't match nested bbcode correctly.   "\[($tag)(=.*)\"\](.*)\[\/\1\]"  // It wasn't .* but the non-gready matcher  I don't have the complete regex with me right now, But I had something that looked like that(above).  So is there a way to match bbcode efficiently with regex or something else.  The only thing I can think of is to use the visitor pattern and to split my text with each possible tags this way, I can have a bit more of control over my text parsing and I could probably validate my document so if the input text doesn't have valid bbcode. I could Notify the user with a error before saving anything.  I would use sablecc to create my text parser.   Any better idea? or anything that could lead to a efficient flexible bbcode parser?  Thank you and sorry for my bad english...
Product rule intuition Can anyone think of an intuitive explanation of the product rule? I'm not asking for a derivation. To me it seems like quite an un-untuitive result, as apposed to the chain-rule (which is ironically harder to derive). @class vs. #import It is to my understanding that one should use a forward-class declaration in the event ClassA needs to include a ClassB header, and ClassB needs to include a ClassA header to avoid any circular inclusions. I also understand that an #import is a simple ifndef so that an include only happens once.  My inquiry is this: When does one use #import and when does one use @class? Sometimes if I use a @class declaration, I see a common compiler warning such as the following:     warning: receiver 'FooController' is a forward class and corresponding @interface may not exist.   Would really love to understand this, versus just removing the @class forward-declaration and throwing an #import in to silence the warnings the compiler is giving me. Please help me out with this problem:  Let $f_n(x) : [0,1] \to \mathbb R$ be a sequence of continuous functions convergent at every $x \in [0,1]$ to a continuous function $f: [0,1]  \to \mathbb R$ . Does $f_n$ converge uniformly to $f$?  My first solution: I read this example in  posted earlier and I think it works: Take a sequence $f_n:[0,1] \to \mathbb R$ such that $f_n$ increases linearly from $0$ to $1$ on the interval $\left[ 0,\frac{1}{n} \right]$, decreases linearly from $1$ to $0$ on the intreval $\left[ \frac{1}{n}, \frac{2}{n} \right]$, and is $0$ on $\left[ \frac{2}{n},1 \right]$. Then $f_{n} \to 0$ nonuniformly.  Is this answer true? Also, if anyone can give some examples of such function with detailed proof, I will very appreciative? Automatic left and right commands Is it possible to automatically "add" \left and \right commands in front of all brackets? The source code should be left intact, but LaTeX should interpret every pair of brackets as if they were preceded by such commands. This is because adding \left and \right commands is time consuming and makes source code longer and less readable. I considered defining new commands such as \lb and \rb for \left( and \right), but it doesn't seem very elegant to me: what if I also want to add square brackets for example?  Any ideas? Thanks. How do you get \mathbb{1} to work (characteristic function of a set)? I am trying to get the digit one printed the \mathbb{} font in math mode, however the command  \mathbb{1}   outputs some rubbish. I certainly saw the character I am after in some pdf's generated from latex, hence my question: how do you get it to work? Let $P(x)$ be a degree $n$ polynomial with distinct roots $r_1, r_2, \cdots r_n$. Prove that   $$\displaystyle\sum_{i=1}^{n}\frac{P''(r_i)}{P'(r_i)}=0$$  My proof: We can equivalently rewrite the polynomial as $(x-r_1)(x-r_2)\cdots(x-r_n)$ and if we plug in the roots in the polynomial, we get that all of them are equal to $0$ so their first derivatives are equal to $1$ and then their second derivatives are equal to $0$ which means that all quotients are equal to $0$ and there for the sum is as well, $Q.E.D$  Don't show the solution please, but if you have a hint, feel free. Thank you. How to use variable inside parameter $_GET? example: ($_GET[$my_var]) "is" operator behaves unexpectedly with integers Why does the following behave unexpectedly in Python?  &gt;&gt;&gt; a = 256 &gt;&gt;&gt; b = 256 &gt;&gt;&gt; a is b True           # This is an expected result &gt;&gt;&gt; a = 257 &gt;&gt;&gt; b = 257 &gt;&gt;&gt; a is b False          # What happened here? Why is this False? &gt;&gt;&gt; 257 is 257 True           # Yet the literal numbers compare properly   I am using Python 2.5.2. Trying some different versions of Python, it appears that Python 2.3.3 shows the above behaviour between 99 and 100.  Based on the above, I can hypothesize that Python is internally implemented such that "small" integers are stored in a different way than larger integers and the is operator can tell the difference. Why the leaky abstraction? What is a better way of comparing two arbitrary objects to see whether they are the same when I don't know in advance whether they are numbers or not? pgfplots external with large dataset (lualatex?) I have fairly large datasets with densely strucutred data that i cant downsampe much without loosing structure. I use TexMaker on Ubuntu 14.04LTS. I use   \usepackage{tikz,pgfplots,pgfplotstable} \pgfplotsset{compat=1.9} \usepgfplotslibrary{external} \tikzexternalize   and   \tikzsetnextfilename{figs/test1}   to externalize the figures. This works good compiling with pdflatex -shell-escape. But as the data becomes to large I am out of memory. I am trying to compile using LuaLaTeX -shell-escape instead of pdfLatex but get the following error message:   ! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error -interact ion=batchmode -jobname "figs/test1" "\def\tikzexternalrealjob{article}\input{ar ticle}"' did NOT result in a usable output file 'figs/test1' (expected one of . pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. For pd flatex, this is 'pdflatex -shell-escape'. Sometimes it is also named 'write 18' or something like that. Or maybe the command simply failed?   so pgfPlots seem to call pdfLatex without the appropriate -shell-escape flag and without me specifying it. How can i get this to compile in LuaLatex? or can i compile only the figures in LuaLatex and the rest in pdfLatex (the opposite of what is happening now)? I found  and  example but neither helped me...  Thankfull for help and i am also thankful for any general advice that can help me resolve the problem of ploting larger data sets in pgfplots.   Cheers /J Rescuing/Compiling old TeX file starting with “\input amstex” I have come across an ancient (1995) LaTeX file which was (surely) once compliant, but now does not compile at all. Is there any way to rescue it?  My actual question is much more precise. I want a copy of the follow paper on the arXiv:    Downloading the pdf source produces something which looks like a document on a4 paper printed on US letter (the bottoms of some pages are cut off). However, if you download the TeX source from the arXiv, then it doesn't compile (even adding .tex, naturally). I'm using an up to date version of TeXshop on a mac. How to find unused/dead code in java projects Can we use media9 to show a video on a PDF but the video is not embedded to the PDF? I have video tutorials that I want to show in my presentation with beamer class. I don't want the video files get embedded to the PDF because they will make the PDF size very very huge.  If you know how the videos can be played on the HTML with a reference rather than embedding the video file to the HTML file, I want something like this to be applied to my PDF presentation. I just want to reference the video URL from my PDF presentation.   Shortly speaking, can we use media9 to show a video on a PDF but the video is not embedded to the PDF?  Uploading those videos to a web server might be difficult for me because internet connection is very slow and sometimes not available in the presentation room. :-) Chain-calling parent initialisers in python In the series finale, Admiral Janeway travels back to 2378 to take Voyager back to Earth. Out-of-universe, of course, this point in time was chosen to fit in with the continuity of the rest of the series. In-universe, however, it seems that Janeway could have chosen any point in time, since she had the ability to travel to and from the Delta Quadrant at will. Is there a reason given, in-universe, for why she chose that particular incident to travel back to? "Overclocking" an AVR In AVR datasheets under the Electrical Characteristics section you will typically find a graph like this (this one is from the ATMega328):    I've seen designs that seem to "work" but operate outside the shaded envelope. Specifically, I've seen 3.3V (Arduino) designs that run the clock from an external 16MHz crystal. Clearly, this is out of spec. What are the practical negative consequences of running outside this envelope? Cell copy results in jaggy, aliased output Is it possible to create bootable linux on USB drive using windows command line? Duplicating Environments Spinning bike's pedals are way bigger than the cleat pedals I have. What size do I need? How do I place a bootable ISO on a USB drive?