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
C

cp9876

@cp9876
About
Posts
770
Topics
4
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How code has changed since the Apollo 11 Moon landing
    C cp9876

    Downloading the software has changed a bit as well: Software written by MIT programmers was woven into core rope memory by female workers in factories http://en.wikipedia.org/wiki/Core_rope_memory[^] no last minute bug fixes and definitely no 'Windows Update'.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Insider News com

  • Two more physics things....
    C cp9876

    The car one is complicated as to whether the brakes in the stationary car are on. If the brakes are off, then both cars end up moving at 40 (conservation of momentum) and so the energy lost in the collision is the same in both cases. If the brakes are on then the energy dissipated (and shared on the occupants) is higher in the stationary car case. The usual example is the choice of stopping dead by running into an identical car at 40, or stopping dead by running into a brick wall at 80, here the brick wall case has 2x the energy to wreak destruction.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge game-dev performance question

  • Someone filed a patent partially based on my source code on CodeProject
    C cp9876

    If you think that you invented something, disclosed in your article, that this other person has patented then their patent will fail as your article will count as prior art in the public domain and they cannot patent that. If you think they have, wait for the examination process and submit an objection. So they cannot be patenting something you invented and disclosed in your article. It appears more likely that they used the code in your article as part of the implementation they reveal in the patent application. As you mention there are other examples on the web they could use, but they chose yours - you should probably be flattered. If this is the case, they haven't actually patented your code, but used it to illustrate how to implement their invention. I understood that the idea of CPOL articles was that the author wanted them to be used by others, commercially or otherwise. Authors do expect some sort of recognition, and the removal of copyright notices is rude and clearly unethical, but I'd be interested if anyone can shed light on whether it is actually illegal. When you submit a patent application you have to provide enough information to enable someone to reproduce the invention, so where software is concerned you provide code. I have no idea whether the authorship of CPOL code has to be disclosed, but it is an interesting question. Including anything substantial in a patent application without attribution would appear to be plagiarism of some form.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    modified on Thursday, April 28, 2011 11:48 PM

    The Lounge c++ html com algorithms tutorial

  • Alternative Vote
    C cp9876

    Dalek Dave wrote:

    It leads to weak government and favours the smaller parties.

    Have you been drinking?

    Dalek Dave wrote:

    I shall be voting no as I do not want the third person in an election getting the seat.

    This is absolutely impossible in a three horse race, and almost unheard of in any race. The problem with FPTP is that you very often get a candidate that is not the preferred candidate of the majority.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge question

  • Alternative Vote
    C cp9876

    I think most people see the fairness of runoff elections (Exhaustive_ballot[^]), where in the first ballot if one candidate gets more than 50% then they are elected, otherwise the candidate with fewest votes is excluded an there is a second ballot. This process continues until someone gets 50%, possibly in a final ballot with two candidates. Here you can express your preference for a minor party candidate in an early ballot but still have your vote counted in the final runoff vote. AV provides an efficient mechanism to achieve a very similar outcome in a single vote. The problem with FPTP is that spoiler candidates change the outcome of an election. For example, using simplistic left/right wing notions, say an electorate in a two horse race will elect a right wing candidate 60:40. In a three horse race with two right wing candidates, if the vote splits 30:30:40 then the left wing candidate gets elected, whereas 60% of the electorate would prefer one of the right wing candidates. In AV, assuming the preferences flowed between the right wing candidates, then the highest polling right wing candidate would get elected. AV (or preferential voting) is not perfect, you do get preference deals between parties, but it does make every vote count. You can get bad examples in both systems, but my view is that it is easier for FPTP to produce unrepresentative results. I guess in the UK with the emergence of a strong third party, then changing systems may favour one side, so the debate is likely to be tinged with self interest. If anyone thinks the Australian system is unpopular or seen as undemocratic (all rubbish) check here: http://blogs.abc.net.au/antonygreen/uk-alternative-vote-referendum/[^], one of our popular election commentators who is in the UK currently, blogging on the debate about the referendum.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    modified on Sunday, April 24, 2011 11:24 PM

    The Lounge question

  • Preprocessor directives - resources
    C cp9876

    We've been using this since VC6 to have customised menus, dialogs, bitmaps etc in different builds. I just checked VC6 and it appears that in VC6 you can add a preprocessor condition to any resource item EXCEPT string tables, these seem to only depend on language. We skipped VS2003 so I can't comment on what you can do there, but if there is no Condition field in the Properties window on string tables then I guess it isn't supported yet. Just look at the properties windows for other resources (e.g. menus) and you should see the Condition field. You should be able to use the same syntax in the .rc file that VS uses for other resources dependent on preprocessor definitions, and use the same in string tables. For example, a menu that is only included when DEFINE1 is defined appears as:

    #if defined(APSTUDIO_INVOKED) || defined(DEFINE1)
    #if defined(APSTUDIO_INVOKED)
    IDR_MENU1$(DEFINE1) MENU DISCARDABLE
    #else
    IDR_MENU1 MENU DISCARDABLE
    #endif
    BEGIN
    POPUP "Menu1"
    BEGIN
    MENUITEM "Help", ID_HELP_X
    ...
    ...
    END
    END
    #endif

    I'm not sure about the APSTUDIO_INVOKED, it seems to use two different mechanisms for the conditional inclusion, one for the IDE and the other for a command line version. You should be able to create a couple of conditional menus or other resources and check the syntax of the .rc file. Don't forget that you specify these defines under the Resources settings in the Project settings.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC tutorial c++ windows-admin question learning

  • Preprocessor directives - resources
    C cp9876

    Not sure what version of VS you are using, but in VS2005 you could: - extract the particular strings to a separate string table - in VS, highlight the string table in Resource View, right click and show properties - in the Condition field you can specify some preprocessor define - e.g BUILD1, this should now be added to the name of the string table - right click on the string table and Insert Copy, and add your new condition on the copy - e.g. BUILD2 - create multiple builds of the project, and set the preprocessor defines in Project Properties / Resources / General

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC tutorial c++ windows-admin question learning

  • Wheelie bin hangs from power lines after floods
    C cp9876

    Something you don't see every day http://www.abc.net.au/news/photos/2011/01/18/3115275.htm[^]

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge csharp announcement

  • Queensland Floods
    C cp9876

    They had a few days warning and saved a lot of stuff. A lot of places went under several metres though, and are now filled with mud. The deaths and destruction was a bit further west where some really heavy rain fell and rivers rose 5-10 metres in an hour. These were the flash floods where people looked out and saw the river rising, made a few phone calls or started packing and the next thing they knew is that they were trapped. Most of these were in places that were not known for flooding, see one brief account here Toowoomba floods a joke no more [^] All this water then went on to contribute to the floods in Brisbane. The dam peaked at 188% and is already back to 120% in case of further rain. Also, quite a few of the tributaries come in below the dam so are not controlled (I think about 1/3 of the catchment feeds downstream).

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge csharp announcement

  • Queensland Floods
    C cp9876

    I don't know if this does justice to the scale of the disaster, but these interactive before and after images are interesting: http://www.abc.net.au/news/infographics/qld-floods/beforeafter.htm[^]

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge csharp announcement

  • What wrong with this loop?
    C cp9876

    Or even easier to understand:

    //CListCtrl m_List;
    int count =m_List.GetItemCount();
    for (int i=0;i<count;i++)
    {
    //do someting with item i
    }
    m_List.DeleteAllItems();

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC question

  • I'm Looking For An Algorithm To Optimize Keno Selections
    C cp9876

    This problem has been well worked over, if you google Keno Probability you can even find source code to work out the expected return over a range of bets. From what I have seen though, all expected returns on $1 are less than $1, so on average you will come out in front if you leave the dollar in your pocket. Where I live these are simple government revenue raising schemes that prey on the vulnerable (somewhat ironically the same folks the government supports).

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    Algorithms question game-dev algorithms tutorial code-review

  • Looking for a mathematical formula
    C cp9876

    Number of ways of choosing m from n is nCm. The number of times a particular card is used (touched) is (n-1)C(m-1). In case this is homework I'll leave the explanation to you.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge tutorial question

  • Cricket - First innings victory to Aust
    C cp9876

    This English team is a disgrace, they are so focussed on their cricket they never sledged Mitch into action. It took our selectors to drop him, then the press got stuck into him and today he took it out on the poms. That'll show 'em.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge

  • If you don't like Cricket, please ignore this thread as you'll only end up getting upset
    C cp9876

    Big stories in the national press here are about unseasonally heavy rains devastating crops, our epic fail of a world cup bid (only one vote) and the cricket. One headline writer summed it up nicely: "This is how it feels to be English. We're whingeing about the weather, the World Cup and an under-performing cricket team."

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    The Lounge php com tools question

  • TIL...... [modified]
    C cp9876

    for Bernard proveth that if p > 7 then

    p^6 = 1 + 84n

    and thus 84 is the full proven truth, twice the truth of 42. However 84 is but an imposter of the full proven truth. As Bernard showeth, for p an odd prime, p^3 is an odd number, and consequently both (p^3 - 1) and (p^3 + 1) are even, but as they are consecutive even numbers then one must be divisible by 4, hence:

    (p^6 - 1) = (p^3 - 1) * (p^3 + 1) = 2*a * 4*b = 8*a*b

    Thus we have the next full proven truth that

    p^6 = 1 + 168n

    But there is more... As p is prime, then the residue modulo 9 shall be one of {+/- 1, +/- 2, +/- 4} which using the fact that 2^3 = 8 = -1(mod 9), and 4 = 2^2 so 4^3 = 2^6 = 1(mod 9), then p^3 = +/- 1 (mod 9), then p^6 = 1 (mod 9) and hence:

    (p^6 - 1) = 9*c

    And so we have the next proven truth that if p is prime and p is not 2,3 or 7 then:

    p^6 = 1 + 504n

    and the full truth is that there is no number higher than 504 to satisfy this.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    Algorithms question

  • Every time I format my system, I get a different MAC address (Windows XP, VISTA and Windows7). Why I am not getting same MAC every time?
    C cp9876

    Is there any reason why you are using the AdaptorName member of PIP_ADAPTER_INFO rather than the Address member?

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC help python sales question

  • TIL...... [modified]
    C cp9876

    NeverHeardOfMe wrote:

    If p is prime, then p ^ 2 = 1 + 24 * n, for some n Don't know about you, but I think that's quite amazing. Why is it true at all, and given that it is, where does 24 come from?! (Pity it's not 42 really!)

    It only needs a small modification to use 42: If p is prime and p > 7 then

    p^6 = 1 + 42n for some n

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    modified on Wednesday, November 10, 2010 11:37 PM

    Algorithms question

  • What is the best way to break (return) from OpenMP loop?
    C cp9876

    Chesnokov Yuriy wrote:

    it needs to prevent further processing in case of the single error even the next some other parallel returned correctly

    That's why you want to do it, now you have to find a way to tell the compiler how to do it in one of the standard ways that it knows how to parallelise. Currently you are telling it that if RunFunction(object[n]) is false then it must not execute RunFunction(object[n+1]), and I don't think any compiler will know how to parallelise that.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC question

  • What is the best way to break (return) from OpenMP loop?
    C cp9876

    I'm no OpenMP expert, but isn't this an example of an algorithm that can't be paralleled as it is written. Imagine two threads, so it runs (0,1), then (2,3), but what if the return value of RunFunction(object[2]) says that the loop should stop, we have probably already executed RunFunction(object[3]). It is not easy to come up with a way that stops a parallel loop with the same result as stopping a sequential loop.

    Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

    C / C++ / MFC 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