Skip to content

Clever Code

Showcase your best code, your most elegant solution, or your most hard fought subtle bug you've found and fixed

This category can be followed from the open social web via the handle clever-code@forum.codeproject.com

361 Topics 3.2k Posts
  • God Bless them.

    database c++ php mysql wpf
    16
    0 Votes
    16 Posts
    11 Views
    B
    Andrew Torrance wrote: So a student who you had responsibility for was ignorant of a short cut , you showed it to him and then mock him ? Must be a nice working environment , I see you at fault here more than him. Andrew please read the very last thing i said. Then I also to stop making assumptions. In you statement I noticed claimed that the "student" (I'll get back to that) was my responsibility. Unless you know how I organize my development structure please keep your comments to yourself. The kid was not my responsibility at all. Also I could swear I never called him a student. Do you think I would post something about someone who is still supposed to be studying? And once again I will have to explain that I, at no point, tried to make him feel stupid or ignorant. I simply stated his own feelings which i assured him were unfounded. People should watch what they say. Brad Australian Have you tried Rebooting it?
  • 0 Votes
    3 Posts
    3 Views
    M
    From the documentation for ClipCursor... "The cursor is a shared resource. If an application confines the cursor, it must release the cursor by using ClipCursor before relinquishing control to another application"
  • Getting the hierarchy wrong

    7
    0 Votes
    7 Posts
    6 Views
    S
    I took a job during the .com bubble and calculated my hourly wage the first month as less than minimum wage. I look for much more stable work environments lately. The place I'm at now is pretty good. But we digress. Scott
  • 0 Votes
    2 Posts
    4 Views
    A
    - WM_USER should not be used on Win32, WM_APP should be used instead - Window messages are of type UINT, not int - Who posts the WM_QUIT message? What happens if the thread terminates before the WM_ASK_THREAD_TO_DO_TASK gets processed? WaitForMultipleObjects ([hThread, hTaskComplete]) would solve that problem. - Where and when is the thread message queue created? PostThreadMessage might fail. - Why is the TranslateMessage and DisptachMessage not in an else branch? Otherwise the whole code is pointless, why tell another thread to execute a function and then wait for the thread? Does the function have to be executed on the UI thread?
  • Freaky Flash

    css adobe sysadmin sales help
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Listen to what the compiler is saying...

    question
    6
    0 Votes
    6 Posts
    4 Views
    J
    Antony M Kancidrowski wrote: We can all have one of those days, this must have been one of them! That so good with those days: there are enough of them for anyone...:laugh: "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.
  • C# yield operator with argument validation

    csharp html com question
    6
    0 Votes
    6 Posts
    6 Views
    J
    Ian MacLean wrote: how does it throw nothing This is something borrowed from functional programming -- the delayed execution part, not the no-exception throw. Under the hood, the C# compiler generates a class that implements IEnumerator, containing all captured local variables. Each time foreach is iterated (which corresponds to IEnumerator.MoveNext() method call), the next line would be yielded. Because of this delayed execution, you can pull of some pretty amazing things, such as yielding every even integer without having to allocate an array of size int.Maximum, or yield recursive hierarchies without having to allocate lists, and so on. But it does introduce subtle bugs like the one above. Tech, life, family, faith: Give me a visit. I'm currently blogging about: God-as-Judge, God-as-Forgiver The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
  • Deleting temporary files from a folder

    help csharp database sysadmin business
    2
    0 Votes
    2 Posts
    3 Views
    M
    Hi! Leaving temp files on the disk for longer than absolutely neccessary is a potential security risk. Shouldn't you remove the temp files as soon as your app doesn't need them any more instead of deleting files of a certain age? Regards, mav -- Black holes are the places where God divided by 0...
  • Copy constructors and operator=

    testing beta-testing question
    8
    0 Votes
    8 Posts
    3 Views
    M
    In: foo a; foo b = a; the second line is equivalent to: foo b(a); That is, construct b as a copy of a. That's why the copy ctor is called. --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
  • Missing '=' in if-statement

    learning
    26
    0 Votes
    26 Posts
    34 Views
    P
    cool, thanks!
  • This little one caused me a week.

    help
    1
    0 Votes
    1 Posts
    1 Views
    No one has replied
  • Double Trouble

    help css
    2
    0 Votes
    2 Posts
    2 Views
    D
    Floating point numbers are stored as base 2 not base 10, which means that they have a different set of infinite repeating decimals. .1 is a base2 infinite repeater. If float didn't have a problem you were probably lucky and had it round up and the error truncate away. Decimal is a base 10 representation, and consequently much slower than native floating types. It does however behave exactly like the user naive expectation.
  • 1+1=3

    help design debugging question learning
    9
    0 Votes
    9 Posts
    6 Views
    E
    Assigning 2 to 1 would overwrite the value of 1 in some early languages. I don't remember which one I just remember it from comparative languages. On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
  • 0 Votes
    1 Posts
    1 Views
    No one has replied
  • IMPLEMENT_DYNAMIC, DECLARE_DYNAMIC problem

    help c++ php com discussion
    1
    0 Votes
    1 Posts
    2 Views
    No one has replied
  • C# Anonymous delegates issue

    help csharp debugging
    5
    0 Votes
    5 Posts
    6 Views
    X
    Perhaps that's why in java, when local variables from the methods are being used by anonymous inner classes, it must be declared final.;P
  • Bit fields, get that type-spec right [modified]

    help
    2
    0 Votes
    2 Posts
    3 Views
    K
    The bit field specifiers aren't ignored if it can fit on byte's length : byte month : 4; // 1 - 12 byte day : 4; // 1 - 16 This will fits in a byte ! To be sure everything to be in your uint, always stuff things like you done with 'res' to fill everything... Kochise In Code we trust !
  • Javascript flaw

    help javascript html com
    6
    0 Votes
    6 Posts
    3 Views
    S
    A day in which time is moved forward or backward with one hour. http://en.wikipedia.org/wiki/Daylight_saving[^] ---------- Siderite
  • Caution! No sign ahead!

    c++ com help learning
    10
    0 Votes
    10 Posts
    7 Views
    G
    PJ Arends wrote: I do have a question about the performace of the code you supplied. Are you not taking a major performance hit by declaring double k inside the loop? Would it not be better to have declared k outside the loop, the same place as you declared v and s? Where you declare a variable only decides it's scope, it doesn't change when it's allocated. All variables that are declared anywhere in a method are allocated when the method is called. The stack pointer is moved to create the neccesary space on the stack for all the variables. --- b { font-weight: normal; }
  • Windows Installer BSOD

    beta-testing announcement c++ database testing
    2
    0 Votes
    2 Posts
    2 Views
    R
    :laugh:. Never knew a font could cause a BSOD! -- Ranju. V http://blogorama.nerdworks.in --