Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
J

John Hunley

@John Hunley
About
Posts
9
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • for(int i=0; i<size; i++)
    J John Hunley

    I personally use x (and y and z for nested loops - if you nest more than two levels, you need to redesign), I make it unsigned (unless there's a specific reason to use signed) because that more accurately models the real world, and I use the prefix form of the increment operator because it's potentially more efficient. So my canonical form of that construct would be:

    for (unsigned x = 0; x < size; ++x)

    And yes, some of my co-workers make fun of me. The ones who spend twice as much time debugging their code as I do debugging mine.

    The Weird and The Wonderful csharp c++ java question

  • List Your "Favorite" Corporo-speak Buzzwords/Phrases
    J John Hunley

    Nowadays, any noun can be verbed.

    The Lounge learning

  • Efficiency redux
    J John Hunley

    We were using a 2x20 character display, so the "gas gauge" went from 0 to 20 bars.

    The Weird and The Wonderful ruby

  • What about this gem?
    J John Hunley

    Actually, that would be a very logical thing to do if the size of the array could change and the requirement was that the last element of the array be set to that particular value. If that's the case, I'd prefer the "1" to be a const int rather than hardcoded. And some comments would also be nice.

    The Weird and The Wonderful csharp ruby data-structures question

  • Efficiency redux
    J John Hunley

    Just unearthed the following gem to display a progress bar:

    // display the battery gauge and percentage
    switch(uiBattBarPosition)
    {
    case(0):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"");
    break;
    case(1):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff");
    break;
    case(2):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff");
    break;
    case(3):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff");
    break;
    case(4):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff");
    break;
    case(5):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff");
    break;
    case(6):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff");
    break;
    case(7):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(8):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(9):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(10):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(11):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(12):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(13):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(14):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(15):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(16):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(17):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(18):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CHARGE),s,"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff");
    break;
    case(19):
    DisplayMessage(MAC_MSG_PTR(SS_BATTERY_CH

    The Weird and The Wonderful ruby

  • Shouldn't programmers know how to fix computers?
    J John Hunley

    I don't so much mind putting an icon on my desktop (although most installers will ask whether or not to do this), but I had one app that not only automatically updates itself, but rearranges all of my desktop icons when it does so. I keep my icons organized on the right side of my desktop, specifically so that I can tell if something has added one without my permission (it'll always be in the upper left corner). This app comes in and moves them all to the upper left corner and down the left side, and gets them all out of order to boot. I have stopped using that app. And yes, I could have turned off automatic updates, but it still rearranged the icons even when I did a manual update.

    The Lounge help tutorial question

  • Why is dates so difficult?
    J John Hunley

    A better question is, why are grammar so difficult?

    The Weird and The Wonderful question

  • Do you not understand booleans?
    J John Hunley

    Just ran across this in code I've been asked to maintain (no kidding):

    if (((ucGlobalHeaterEnable & (1 << UC_BHOSE_HTR_ON) ) > 0) ? 1 : 0)
    {
    ...
    }

    Unbelievable!

    The Weird and The Wonderful data-structures question announcement

  • What could they have been thinking?
    J John Hunley

    Recently my group was asked to troubleshoot an embedded program written by our overseas sister company, which was "never coming up" and their engineers(?) couldn't figure out why. A few seconds of perusing revealed the following in the middle of the program's initialization code:

    for (long i = 0; i < 99999L; i++) dlytsk(cur_task, DLY_SECS, 9999);

    The dlytsk function causes the calling task to sleep for the specified number of seconds. So the effect of this snippet was to sleep for around 32 years before allowing initialization to complete. One has to wonder what the original intent was (both of the programmer and the manager who hired him!).

    The Weird and The Wonderful hardware help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups