Click here to Skip to main content
15,499,571 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: How To Use Session Variables Pin
BrainiacV20-Jun-13 6:44
MemberBrainiacV20-Jun-13 6:44 
GeneralRe: How To Use Session Variables Pin
jcmaida20-Jun-13 7:10
Memberjcmaida20-Jun-13 7:10 
GeneralRe: How To Use Session Variables Pin
Bob100020-Jun-13 5:44
professionalBob100020-Jun-13 5:44 
GeneralRe: How To Use Session Variables Pin
User 483504720-Jun-13 4:25
MemberUser 483504720-Jun-13 4:25 
GeneralRe: How To Use Session Variables Pin
RafagaX20-Jun-13 5:44
professionalRafagaX20-Jun-13 5:44 
GeneralRe: How To Use Session Variables Pin
Member 882490521-Jun-13 4:28
MemberMember 882490521-Jun-13 4:28 
GeneralRe: How To Use Session Variables Pin
AnalogNerd21-Jun-13 5:01
MemberAnalogNerd21-Jun-13 5:01 
GeneralA Brilliant Replacement of float.toFixed(2) Pin
TNCaver17-Jun-13 10:25
MemberTNCaver17-Jun-13 10:25 
Our finance folks were a bit annoyed by one of our web pages, where it occasionally rounded the final total to the nearest dime. While troubleshooting a former colleague's JavaScript code that added 2% to the amount entered by the user, I found this gem. His intention, at least, was obvious by the function name.

JavaScript
function CurrencyFormatted(amount) {
	var i = parseFloat(amount);
	if (isNaN(i)) { i = 0.00; }
	var minus = '';
	if (i < 0) { minus = '-'; }
	i = Math.abs(i);
	i = parseInt((i + .005) * 100);
	i = i / 100;
	s = new String(i);
	if (s.indexOf('.') < 0) { s += '.00'; }
	if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
	s = minus + s;
	return s;
}

Isn't that brilliant? I mean, why use the simple, single-line solution isFixed(2) when you can do the same thing in 9 lines? WTF | :WTF:
If you think 'goto' is evil, try writing an Assembly program without JMP.


modified 17-Jun-13 16:15pm.

GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
LloydA11117-Jun-13 10:33
MemberLloydA11117-Jun-13 10:33 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
Marc Clifton18-Jun-13 6:30
mvaMarc Clifton18-Jun-13 6:30 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
AlphaDeltaTheta18-Jun-13 18:17
MemberAlphaDeltaTheta18-Jun-13 18:17 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
Brisingr Aerowing19-Jun-13 4:08
professionalBrisingr Aerowing19-Jun-13 4:08 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
TNCaver20-Jun-13 6:06
MemberTNCaver20-Jun-13 6:06 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
Bob100020-Jun-13 5:46
professionalBob100020-Jun-13 5:46 
GeneralRe: A Brilliant Replacement of float.toFixed(2) Pin
TNCaver20-Jun-13 6:12
MemberTNCaver20-Jun-13 6:12 
GeneralDatetimes in java (again) Pin
V.13-Jun-13 2:22
professionalV.13-Jun-13 2:22 
GeneralRe: Datetimes in java (again) Pin
BotCar13-Jun-13 2:38
MemberBotCar13-Jun-13 2:38 
GeneralRe: Datetimes in java (again) Pin
Brisingr Aerowing13-Jun-13 3:58
professionalBrisingr Aerowing13-Jun-13 3:58 
GeneralRe: Datetimes in java (again) Pin
Rob Grainger18-Jun-13 2:00
MemberRob Grainger18-Jun-13 2:00 
QuestionMessage Closed Pin
12-Jun-13 22:44
MemberUser 1006066512-Jun-13 22:44 
AnswerRe: HTML 5 Application. Pin
AlphaDeltaTheta12-Jun-13 22:53
MemberAlphaDeltaTheta12-Jun-13 22:53 
GeneralMessage Closed Pin
12-Jun-13 22:57
MemberUser 1006066512-Jun-13 22:57 
GeneralRe: HTML 5 Application. Pin
AlphaDeltaTheta12-Jun-13 23:02
MemberAlphaDeltaTheta12-Jun-13 23:02 
GeneralRe: HTML 5 Application. Pin
User 1006066512-Jun-13 23:16
MemberUser 1006066512-Jun-13 23:16 
GeneralRe: HTML 5 Application. Pin
AlphaDeltaTheta12-Jun-13 23:21
MemberAlphaDeltaTheta12-Jun-13 23:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.