-
Posts
11784 -
Joined
-
Last visited
-
Days Won
2
Content Type
Profiles
Forums
Events
Everything posted by Cap'n Refsmmat
-
Funny to see a thread celebrating 25,000. We have seven times that amount now, I think. In two years.
-
Probably people were standing around a forest fire, and they were nice and warm, and then the lunatic of the group went up and grabbed a burning log and went running around with it. Quickly he learned to hold it by the non-burning end. Voila, a torch. Building campfires would take a bit longer.
-
That might be a bit strong. Oddly, I don't mind bits floating in my lemonade, but I hate pulp in orange juice.
-
NEW Alternative form of energy -- YOU
Cap'n Refsmmat replied to asianpacific's topic in Other Sciences
An add-on to the piezoelectric shoes: A piezoelectric sidewalk. Put it in Times Square or some place with high pedestrian traffic. You could generate quite a bit of electricity off of that. I also know that some farms use the cattle's movement on a pad (not piezoelectric, but mechanical) to pump water out of a well. -
I'll see if I can implement <table> with bbcode instead. Should require a bit of regex as well, and allow me to make all < and > to < and >.
-
That's only sort of possible - for example, it's possible to create viruses that only attack other viruses. Those can be used to destroy the viruses that are attacking the body. In terms of creating an "anti-virus," it might be possible, but a lot of the damage that viruses cause is very complex, and it would be bloody hard to undo it.
-
Would I be correct in saying that strtr() is faster than str_replace()? In my trials it seems so. In 1000 strtr or str_replace repetitions, strtr is faster by .01+ of a second every time. Also: Having trouble making code to replace all < and > with < and > without doing it to <table>, <tr>, <td>, and <th> tags (don't want to have to do bbcode tables).
-
$article_text = eregi_replace("\[url=([^\[]+)\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\2</a>", $article_text); $article_text = eregi_replace("\[url\]([^\[]+)\[/url\]","<a href=\"\\1\" target=\"_blank\">\\1</a>", $article_text); $article_text = eregi_replace("\[img\]([^\[]+)\[/img\]","<img src=\"\\1\" border=\"0\" alt=\"user posted image\"/>", $article_text); That seems to do it. Any potential problems you can see with it? I love google... so easy to find free code. (edit: it seems to have slowed my script down a bit. All this bbcode takes an effect. Let's see if it can be made more efficient...)
-
Yes, indeed. I already do that with [nobb] tags so the text inside isn't parsed like the rest of it. I can just modify that code to do it for URLs, if necessary. But I think it would be easier to just make the thing not parse a url if it's already in an <a href=""> or <img src=""/> tag. A quick addition to the regex, I think.
-
More woes from regexp land... I have this code: $article_text = eregi_replace( "[[:<:]]((http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,10}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\.\,_\?\'/\\\+&%\$#\=~;])*)[[:>:]]", '<a href="\\1">\\1</a>', $article_text); to match URLs and convert them to nice neat <a href=""></a> tags. Now I'm trying to add tags. How would I go about making this not parse the url if the url is enclosed in tags?
-
If you had a book on PCRE syntax I'd be fine. (PCRE = Perl Compatible Regular Expression syntax. preg stuff.)
-
I'll be needing preg, too--bbcode and all that fun stuff. Is ereg_replace just as fast? That's all this book covers. (maybe I should buy one of those "Regular Expressions in a Nutshell" books) edit: dang. Doesn't look like it is. I hate this book.
-
But that's slower to display. I'll fool around and see what I can do. edit: sigh. I guess nothing beats the easy way... Well, thanks a lot for the help, folks!
-
Aha! You had an extra quotation mark there. $article_text = preg_replace('/\[\[(.*?)\]\]/', '<a href="'.$site_url.'index.php?title=\\1">Linkage</a>', $article_text); works. (You had added an extra " after $site.url.') Thanks! Now, to work on un-parsing it for when you edit the page again...
-
Well then. That works (I had accidentally removed something from the original one as well, so it all came out blank) but it links right back to index.php? rather than index.php?title=blah. Hmmm...
-
Never mind that, dave. I forgot to add $article_text = in the front. Although now the text it returns is completely blank... argh. edit: anything comes out blank with your preg_replace in it, now that it actually stores the result to $article_text. Had to comment that out for the moment. I have to give you people some credit; nobody has even replied on WebHostingTalk.
-
Indeed. But to no avail, it seems. Still doesn't work. I'll read up on regex and see what I can do. Thanks for the help, people.
-
No luck. It still comes out unchanged. I'm using the url [[blah]].
-
Dang, you're good. The book I have just doesn't give regex justice. I haven't had much need for it either. I'll test that out in a minute.
-
I've been fooling around with a bit of code lately. It's supposed to convert links like [[link]] in a text to a link like http://www.example.com/index.php?title=link or whatever. Like a Wikipedia link, really. Here it is: while($linkpos = strpos($article_text, "[[", $i) && ($linkpos != FALSE)) { $linkendpos = strpos($article_text, "]]", $linkpos + 1); $link = substr($article_text, $linkpos + 2, ($linkendpos - 1) - ($linkpos + 2)); $newlink = '<a href="' . $site_url . 'index.php?title="' . $link . '" class="interlink">' . $link . '</a>'; $article_text = substr($article_text, 0, $linkpos - 1) . substr($article_text, $linkpos - 1, ($linkendpos + 2) - ($linkpos - 1)) . substr($article_text, $linkendpos + 2, strlen($article_text) - ($linkendpos + 2)); $i = $linkendpos + 2; } Of course, it doesn't work. The text comes out unchanged. At the moment, $article_text is the text that is being parsed. $site_url is the url of whatever the site is. Anyways, you're probably thinking "What was he thinking when he wrote that code?" or something like that. Well, I'm not that great at PHP. I've never had to do regex or string manipulation before, really. I'm living off of the book until I can get enough experience. And I don't have that much, at the moment. Any help would be appreciated. Thanks!
-
http://www.scienceforums.net/forums/showthread.php?t=10378 http://www.scienceforums.net/forums/showthread.php?t=9480 This guy has been discussed before.
-
I guess I'm just used to people with crappy spelling.
-
You'd need to find a set of chemicals that create a very powerful endothermic reaction, to use up all of that heat in the atmosphere.
-
ScienceForums has a history of tolerating certain crackpots for quite a long time before they were finally banned. Adam, Zarkov, etc.
-
http://sayonara.info/blog/