Click here to Skip to main content
15,896,063 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.

 
GeneralIE Invisible DIV Bug Pin
AspDotNetDev28-Jul-10 11:58
protectorAspDotNetDev28-Jul-10 11:58 
GeneralRe: IE Invisible DIV Bug Pin
Luc Pattyn28-Jul-10 12:19
sitebuilderLuc Pattyn28-Jul-10 12:19 
GeneralRe: IE Invisible DIV Bug Pin
AspDotNetDev28-Jul-10 12:23
protectorAspDotNetDev28-Jul-10 12:23 
GeneralRe: IE Invisible DIV Bug Pin
Daniel 'Tak' M.28-Jul-10 13:12
Daniel 'Tak' M.28-Jul-10 13:12 
GeneralRe: IE Invisible DIV Bug Pin
Hired Mind5-Aug-10 11:10
Hired Mind5-Aug-10 11:10 
GeneralRe: IE Invisible DIV Bug Pin
AspDotNetDev5-Aug-10 12:06
protectorAspDotNetDev5-Aug-10 12:06 
GeneralRe: IE Invisible DIV Bug Pin
AspDotNetDev5-Aug-10 12:07
protectorAspDotNetDev5-Aug-10 12:07 
JokeOpinions PinPopular
SirTimothy27-Jul-10 19:38
SirTimothy27-Jul-10 19:38 
Hey folks, I don't generally post on these forums, but I do enjoy the CP newsletters. Anyways, I wanted to share a lovely snippet I wrote a little while ago. Maybe get some opinions? It's a bubble sort in C. It generates 20 random numbers from 0 to 99, and sorts them! Of course, it's fairly straightforward, so I'm sure you could guess that.

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

#define ARRAY_SIZE 20

#define PNT(s, l, a) fprintf(std##s, l, a)
#define PNT2LINES(s, l1, l2, e) PNT(s, #l1#e#l2#e, 0)

void print_array(int *array) {
	int x = ARRAY_SIZE;
	char* fmts[] = { "%d, ", "%d\n" };
	--array;
LBL0:
	if (PNT(out, ((x == 1) & 1)[fmts], *(array = ++array)), --x > 0)
		goto LBL0;
}

main() {
	int iarray[ARRAY_SIZE];
	int x, y;
	int ofs = iarray - &ofs;
	void (*prnt_func)(int*) = &print_array;
	srand((unsigned int)time(NULL));
	x ^= x;
LBL1:
	if ((y = rand(), x < ARRAY_SIZE) && ((((x = x + 1) - 1)[iarray] = (y - (y / 100) * 100)) || 1))
		goto LBL1;
	PNT2LINES(out, Before sort, ---------------, \n);
	(*prnt_func)(&ofs + ofs);
LBL2:
	y = x &= ~x;
LBL3:
	if (y + 1 < ARRAY_SIZE) {
		if ((++y, iarray[y] < (y-1)[iarray]) && (y[iarray] ^= iarray[y-1] ^= iarray[y] ^= *(iarray + y - 1), x |= y));
		goto LBL3;
	}
	if (x = x) goto LBL2;
	PNT2LINES(out, After sort, ---------------, \n);
	(*prnt_func)(&ofs + ofs);  
}

GeneralRe: Opinions PinPopular
OriginalGriff27-Jul-10 20:38
mveOriginalGriff27-Jul-10 20:38 
GeneralRe: Opinions Pin
Rob Grainger27-Jul-10 23:00
Rob Grainger27-Jul-10 23:00 
GeneralRe: Opinions Pin
riced27-Jul-10 23:23
riced27-Jul-10 23:23 
GeneralRe: Opinions Pin
QuiJohn28-Jul-10 2:56
QuiJohn28-Jul-10 2:56 
GeneralRe: Opinions Pin
SirTimothy28-Jul-10 8:14
SirTimothy28-Jul-10 8:14 
GeneralRe: Opinions Pin
Gary R. Wheeler1-Aug-10 0:25
Gary R. Wheeler1-Aug-10 0:25 
GeneralRe: Opinions Pin
PIEBALDconsult28-Jul-10 3:18
mvePIEBALDconsult28-Jul-10 3:18 
GeneralRe: Opinions Pin
elchupathingy28-Jul-10 3:31
elchupathingy28-Jul-10 3:31 
GeneralRe: Opinions Pin
SirTimothy28-Jul-10 8:12
SirTimothy28-Jul-10 8:12 
GeneralRe: Opinions Pin
Luc Pattyn28-Jul-10 8:20
sitebuilderLuc Pattyn28-Jul-10 8:20 
GeneralRe: Opinions Pin
Jörgen Andersson28-Jul-10 5:10
professionalJörgen Andersson28-Jul-10 5:10 
GeneralRe: Opinions Pin
leonej_dt28-Jul-10 6:31
leonej_dt28-Jul-10 6:31 
GeneralRe: Opinions Pin
supercat928-Jul-10 6:59
supercat928-Jul-10 6:59 
GeneralRe: Opinions Pin
dybs28-Jul-10 16:29
dybs28-Jul-10 16:29 
GeneralRe: Opinions Pin
SirTimothy28-Jul-10 16:58
SirTimothy28-Jul-10 16:58 
JokeRe: Opinions Pin
johannesnestler2-Aug-10 3:00
johannesnestler2-Aug-10 3:00 
GeneralRe: Opinions Pin
SirTimothy3-Aug-10 15:54
SirTimothy3-Aug-10 15:54 

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.