Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 19th, 2007, 4:49 PM   #1
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Noob Zapper

I decided, out of boredom, to make our lives easier.

Periodically, one comes across posts similar to the following:

#include <iostream>

using namespaces;; //WTF? this isnt in mah book

int main() {
while (1 + 1 > -2487928746) {
cin >> cout << "hallo wurld!!1one";;

}
}

}

i dunno what's wrong with dis but i have an exam tomorrow kthx


Yes, people need to learn to use code tags, but it's a serious waste of time to nag them and check the thread again later.

I wrote a GreaseMonkey script to automagically wrap stuff in code tags that probably should be. The code kind of looks like a bunch of duct-tape, which it is, but it works reasonably well for the poorly tagged posts that I've tried it on (which were kindly annotated with flaming and thus easy to search for).

You need GreaseMonkey installed in a compatible browser to use the script.

Get the script here.

Make sure the little monkey icon is smiling (click to toggle GreaseMonkey on and off) and browse around for naked code.
Subtle Hint: Refresh this page

I'll link some good test posts later.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 19th, 2007, 5:00 PM   #2
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Example pages

http://www.programmingforums.org/for...h-my-code.html
Very very simple case

http://www.programmingforums.org/for...-cin-cout.html
Note that the line after the code is properly not included, despite containing code-like elements. I may have to make #include a special case, since it is usually found in the first few lines.

http://www.programmingforums.org/for...g-the-nim.html
Multiple auto-tagged sections in a single post. It possibly should have been one big section, but there was just enough whitespace between them. May need to add detection for // and /* style comments.

http://www.programmingforums.org/for...en-i-use-.html
Note that in post #3, the auto-tagged section stops right before the descriptive text, even though it contains lots of code-like stuff.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 19th, 2007, 5:28 PM   #3
andro
Professional Programmer
 
Join Date: Oct 2005
Location: California
Posts: 290
Rep Power: 3 andro is on a distinguished road
Send a message via AIM to andro
Works great for me
andro is offline   Reply With Quote
Old Aug 19th, 2007, 6:37 PM   #4
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Nice.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Aug 19th, 2007, 7:38 PM   #5
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
New version with an extra button that puts a canned response in the quick-reply area. The message can be changed (or the button disabled completely) in the config section. Right click the monkey, Manage User Scripts, Edit.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 19th, 2007, 8:29 PM   #6
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 927
Rep Power: 4 lectricpharaoh will become famous soon enough
And here I was hoping this 'noob zapper' would deliver a mild electrical shock to the offenders.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old Aug 20th, 2007, 12:11 AM   #7
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 373
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Any reason it doesn't include the #include <iostream> ?

Oh, and if you can make it use [highlight] for every specific language, depending on what section it is, that would be grate :p
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Aug 20th, 2007, 12:53 AM   #8
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Quote:
Originally Posted by xavier View Post
Any reason it doesn't include the #include <iostream>?
Nothing language specific is included currently. Making #include a special case is a very minor change.

Quote:
Originally Posted by xavier View Post
Oh, and if you can make it use [highlight] for every specific language, depending on what section it is, that would be grate :p
I'm not feeling too inclined to reimplement the forum's syntax highlighting tag in Javascript, to be honest . This is purely clientside, remember. [highlight] does not translate to a <highlight> tag, but instead a significant amount of server-generated markup.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 20th, 2007, 1:22 AM   #9
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 373
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Uuu.. didn't think about that .
Good work till now mate. Hope it won't make me too lazy and stop using code tags
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Aug 20th, 2007, 2:18 AM   #10
bigguy
Professional Programmer
 
bigguy's Avatar
 
Join Date: Sep 2005
Location: Arkansas
Posts: 296
Rep Power: 0 bigguy is an unknown quantity at this point
Send a message via AIM to bigguy Send a message via MSN to bigguy Send a message via Yahoo to bigguy
I love it. Nice job
__________________
Forgiveness is the fragrance that the violet sheds on the heal that has crushed it. - Mark Twain

Destruction leads to a very rough road, but it also breeds creation.
bigguy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
asm noob project... Kilo Assembly 10 Jun 11th, 2006 5:36 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:21 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC