I lol'd.
man I love php. I'd be happy working in that language for the rest of my life. Well, prolly not, but I'd be happy with it as a starting career.
The gnarliest regular expression I've ever written
e: jeez, I wrote half of that thing, but it was months ago, and looking at it now, I have no idea how it works. All I remember is that it's for pre-parsing text submitted in a post field to get it ready for the BBCode parser, and my modification added <br>s everywhere a user entered one except following the BBCode tags, which once parsed into HTML can break if extra <br>s are included.Code:preg_match_all("=((\"[^$ce]+\")|([^\s$ce]+))(?=[\s$ce])!i", $str, $attributeArray, PREG_SET_ORDER);
For example, say someone included a list:
[ul]
[li]one[/li]
[/ul]
It would be an error in the HTML for that to be parsed as
<ul><br>
<li>one</li><br>
</ul>
My PM fetcher:
Code:/** * Fetches the private message with my_index = $index from the database and returns it as a * PrivateMessage object, or false on fail. * Requires mysqli database link $dbLink to be active- fails if not. * * @param int Index of desired private message * @return PrivateMessage | boolean Recovered PM, or false if not found * @access public */ static function fetch($index) { if(!PrivateMessage::$dbLink) return false; if(PrivateMessage::$messages[$index]) { if(PrivateMessage::$messages[$index] instanceof PrivateMessage) return PrivateMessage::$messages[$index]; else return false; } if($result = PrivateMessage::$dbLink->query('SELECT * FROM `' . PMTABLE . "` WHERE `my_index` = $index LIMIT 1;")) { if($result->num_rows!=1) return false; $pm = new PrivateMessage($result->fetch_assoc()); $result->close(); PrivateMessage::$messages[$index]=$pm; return $pm; } PrivateMessage::$messages[$index]=""; return false; }
Last edited by Rob Oplawar; May 5th, 2008 at 08:11 AM.
Another work in progress for all you folks (unfortunately the cartoon drawing thing was a very short boredom induced phase, but maybe I'll get back to it someday).
http://www.spacebrick.net/argo.svg
You will need an SVG viewer to view this image- Firefox has one built in and IE has a plugin for it, and you can get standalone viewers for it.
So, what's really cool about it is that that image is defined by just a hundred or so lines of XML, that I wrote by hand just now. I mean, fucking ace, that picture's code, and that code's a picture! I think I'm in love.
e: Use your browser's increase/decrease text size functions to zoom in and out, and right-click and view source to check out the code that produces it. How awesome is that? ;D
Last edited by Rob Oplawar; May 22nd, 2008 at 01:44 AM.
There are currently 4 users browsing this thread. (0 members and 4 guests)
Bookmarks