nezachem 616 Practically a Posting Shark

You are on Solaris, right? Add -lsocket -lnsl to the command line. That will pick up the necessary libraries.

nezachem 616 Practically a Posting Shark

Python QA automation these days is centered around nosetest. Their site is a good starting point.

nezachem 616 Practically a Posting Shark

Line 31 is sort of funny. You need to switch on wParam instead.

nezachem 616 Practically a Posting Shark

I wonder , does it always give the same result or it depends on how much functionality
the thread routine executes?

Can you please rephrase?

using pthread_join blocks the execution of the next statement(s) that is after join until the thread that is waiting on is finished?

Correct.

nezachem 616 Practically a Posting Shark

To begin with, the attr object is not initialized, so calling pthread_attr_getschedpolicy on it is meaningless (thus your output of question marks).

As to scheduling, the shecduler is not deterministict.

Not so.

nezachem 616 Practically a Posting Shark

Literally it is an instruction to sed to prepend a line with s, and append ,g to it.
Say, some line in the replacement file reads
foo,bar
Then, after the sed application it'll become
s,foo,bar,g
which in turn is a sed instruction to replace (s) all (globally) appearances of foo to bar.

To escape bangs you may also use sed, this time with s/!/\\!/g instruction.

nezachem 616 Practically a Posting Shark

Step 1: form a sed script based on the csv file
Step 2: apply sed to all the files you need to modify

Assuming csv (that is, columns are separated with comma, and comma doesn't appear anywhere neither in old nor in new values), the sed script can be trivially formed with a following sed command:

sed -e 's/\(.*\)/s,\1,g/' file.csv script.sed

Now you may apply it as

for file in list_of_files; do sed -i -f script.sed $file; done

I didn't get the escaping part (what and how should be escaped), but it is surely possible.

nezachem 616 Practically a Posting Shark

In this context the process usually means the manufacturing process, as at TSMC. Next generation of the process is switching, for example, from 40 to 28 nanometers.

nezachem 616 Practically a Posting Shark

concatenate the capital letters that are followed by a space

I can think only of a 3-step solution (which looks ugly, but possibly it can be improved):
- replace all wanted spaces with, say, underscores:
s/ \([A-Z][^ ]\)/_\1/g'
- remove all remaining spaces:
s/ //g
- restore wanted spaces:
s/_/ /g'

Something like that...

nezachem 616 Practically a Posting Shark

In the ChanNameVAlign case you want to split at the transition from lowercase to uppercase:
s/\([a-z]\)\([A-Z]\)/\1 \2/g

In the OSDSettings, I don't see a non-contradictory criteria.

nezachem 616 Practically a Posting Shark

Please explain what "not working" means in your situation.

Through the crystal ball I can see that you need to pace out the sampling. A single pin IO usually implies a time-based protocol.

nezachem 616 Practically a Posting Shark

But it has a few mistakes

Granted. Never tested it.

PS: for a 100% architectural correctness, replace 8 with CHAR_BIT. Don't forget to #include <limits.h>

nezachem 616 Practically a Posting Shark

I only have 1 laptop...

Umm... set up few virtual machines there, perhaps.

nezachem 616 Practically a Posting Shark

This is the linker command your gcc generated (I just broke it up into few lines for clarity:

c:/mingw/bin/../libexec/gcc/mingw32/4.6.2/collect2.exe -Bdynamic -u ___register_frame_info -u ___deregister_frame_info -o Pascal.exe c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../crt2.o c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtbegin.o -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2 -Lc:/mingw/bin/../lib/gcc -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../../mingw32/lib -Lc:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../.. -L/mingw/lib
-lgmpxx -lgmp
C:\DOCUME~1\DMS40\LOCALS~1\Temp\ccKxmt7C.o
-lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtend.o

The linker works sequentially, and only puls stuff from libraries to satisfy references, which are currently unresolved. By the time the it sees -lgmpxx and -lgmp, there is nothing yet to link from them. You need to change the order, so that linker accounts your object first So, instead of

$ g++ -v -lgmpxx -lgmp -o Pascal.exe Pascal.cpp

do

$ g++ -v Pascal.cpp -lgmpxx -lgmp -o Pascal.exe 
nezachem 616 Practically a Posting Shark

APPARENTLY broadcast is dead, long live multicast

Multicast is great after the server is established, whch is not the case initially. I should have emphasize, that everything I said applies to the LAN environment only. It would be very hard (if posiible at all) to implement discovery over pure WAN.

nezachem 616 Practically a Posting Shark

Objection! This solution presumes architectural details not mentioned in the problem statement (32-bit values).

Here's another log-time solution, which scales for any width:

    for (shift = 1; shift < sizeof(challenge); shift <<= 1)
        challenge |= challenge >> shift;
    answer = challenge & ~(challenge >> 1));

Of course in reality, such program spends most of cycles printing out 10^6 test cases.

nezachem 616 Practically a Posting Shark

First of all, you cannot manipulate names. A name is a property of a computer, and it should stay intact. What you need is to allocate a port over which the game communications would occur. This port number is to be known for all participating computers in advance.

In the discovery phase, the game shall broadcast the request (that is, send a UDP pachet to a said port at a broadcast address). If the server already exists, it shall reply with its IP address. If nobody replies in a sensible time period (and maybe even after a few retries), the game may assume there's no servers, and create one. Keep in mind that nothing happens instanteneously, so there's a possibility that two or more systems may simultaneously decide to become servers. Yuo need a protocol to detect and arbitrate such race.

Once the server is established, the rest is more or less trivial. I'd suggest to set the discovery stage aside for now. Make the server, and have it running at a known IP address. Let the clients connect to that address. Are there specific questions on how to do it?

nezachem 616 Practically a Posting Shark
str = ("cat %s >> combinedObjects.o", argv[i]);

What in your opinion this line is doing?

nezachem 616 Practically a Posting Shark

I had to emphasize that ls (ell-es) is a command. Run it in the directory whe you run make, and post the output here.

nezachem 616 Practically a Posting Shark

It means that Horse.cpp is not present (at least, in the directory where you run make). What does the ls output look like?

nezachem 616 Practically a Posting Shark

My simple Serial Port code doesnt work.

Can you be more specific?

I see a problem at lines 71/72 (buff is not initialized nor allocated); does your program reach that far?

nezachem 616 Practically a Posting Shark

Size of array is MAX_SIZE. Look at line 118.

nezachem 616 Practically a Posting Shark

You entered 4 elements. How many elements are you actually sorting?

nezachem 616 Practically a Posting Shark

There are very convincing opinions that GPL is legally valid, that is it doesn't contradict the existing laws and precedents. There are equally convincing opinions that it is not. This legal limbo may be only resolved in the court. As far as I know, it didn't happen yet.

Few cases make to a judge ruling on it,

Could you please point me some which did produce a ruling? I am not aware of any (in US), but maybe I didn't search hard enough.

but it seems that it's mostly because the license violators settle it when it becomes obvious that they can't win.

That's exactly the point. Settlement does not prove anything about the validity of the license. Besides, it takes two to settle.

nezachem 616 Practically a Posting Shark

I pointed you to the bug. It is at line 44. What is it supposed to do? What does it do?

nezachem 616 Practically a Posting Shark

Explain line 44.

nezachem 616 Practically a Posting Shark

I believe your C++ code does fall under GPL.

A "derivative work" is defined in the Copyright Act, 17 USC 101, as a:

""work based upon one or more preexisting works, such as a translation, [...] or other modifications which, as a whole, represent an original work of authorship, is a ‘derivative work’."" (see here.

What are the actual laws on copyrighting code

The real question is, does GPL hold water. The answer is, nobody knows (in US at least, and I think it's the same in Canada), because no judge ruled on it yet.

nezachem 616 Practically a Posting Shark

I don't think having a symbol table outside the class (I suppose we are talking of expression class) would destroy anything. It is a very standard application of a singleton.

nezachem 616 Practically a Posting Shark

If I understand your problem correctly, you need a symbol table, which maps expression name to expression instance. std::map would do it just fine.

nezachem 616 Practically a Posting Shark

nezachem is linking to an article that talks specifically about Windows structured exceptions, not C++ exceptions

Possibly. However, the article claims that
Under the hood, true C++ exception handling is implemented very similarly to what I'll describe here.

I still think it is a great introduction into exception handling.

nezachem 616 Practically a Posting Shark

In the valueAt, if the very first comparison fails you immediately enter the else clause and return 0. Get rid of else and move return 0.0 out of the loop.

nezachem 616 Practically a Posting Shark

Great article. A bit old, but still valid.

nezachem 616 Practically a Posting Shark

.

nezachem 616 Practically a Posting Shark

Comeau may help. I never looked at the generated C code; it may well be unreadable by a human being.

nezachem 616 Practically a Posting Shark

The only reason I can think about is that the shells are different. What is in the #! line of the script, and what system you are running at?

nezachem 616 Practically a Posting Shark

You don't know what? I just described how your code works.

nezachem 616 Practically a Posting Shark

Now that I've gone back to look at my equation, I realise that this is just the "Birthday Paradox" with a year of 1000 days, so to speak :)

Wikipedia has a good explanation and a number of equations that come out with the answer I got earlier, which is nice.

So, the question I have is "average number of songs played before there is a repeat" is the 50% mark?

Yes, I think so. There is a number of songs to play at which the probability of hearing a repeat is 50% (well, just over); the question becomes what is that number?

No you are wrong. These are two completely different questions. The answer to average number of songs is given at the same wiki page, but way down below.

Do you see the difference?

nezachem 616 Practically a Posting Shark

Let's pretend that the phonebook has 3 entries: e0, e1 and e2. counter is 3. Then you delete e0. Counter becomes 2. Now when you try to print them, you printing e0 (which is zeroed out) and e1, instead of desired e1 and e2.

There are numerous ways out. You may sort the phonebook after deletion. You may copy the last valid entry on top of the deleted one (instead of clobbering it). You may drop the counter at all in favor of some validity flag. Etc.

nezachem 616 Practically a Posting Shark

Of course not. stosb increments EDI automatically.

thines01 commented: Good catch! +12
nezachem 616 Practically a Posting Shark

There is a number of problems with the code. I don't know where to start.

To address your immediate question (my code will always make the new generation blank), check with the debugger (or just print out) the value of nCount. You will be surprised.

Second, your display() function is really funny. It displays the original board (once), and then goes on to display the same newBoard (which never changes anymore) for 50 times.

Third, your neighbour counting is plain wrong. In the game of life all 8 neigbours count, along with the cell itself.

Finally, when counting neighbours you have your indices backward (board defined to have first index in 0..69, and second index in 0..19), and you do step outside the board.

That's all I see with the naked eye. Maybe, there's more, but that's enough to keep you busy for now.

nezachem 616 Practically a Posting Shark

Return from the function with a return statement and the program will continue to run from that point on

This is quite hard to do considering that "some error" can be a segfault. The OP goal is achieved via setjmp in the caller and longjmp from the signal handler.

nezachem 616 Practically a Posting Shark

I don't think a linked list is a right approach. You need a dependency graph, along the lines of

struct gate {
    bool result;
    bool resolved;
    gate * dep1;
    gate * dep2;
};

To calculate the output, you just simply traverse the graph starting from the output gate (remember, pull is almost always better than push):

gate::calculate()
{
    if(!resolved) {
        bool val1 = dep1->calculate();
        bool val2 = dep2->calculate();
        result = nand(val1, val2);
        resolved = true;
    }
    return result;
}

Of course, if some gates require more than one input (and/or perform functions other than nand), replace dep1 and dep2 with std::vector<gate *> dependency , and replace nand a virtual method.

nezachem 616 Practically a Posting Shark

Am I right?

No. The y++ differs from ++y in the value calculated by the operator. A side effect still happens at an unspecified moment somewhere prior to a sequence point. The behaviour is still undefined.

nezachem 616 Practically a Posting Shark

Correction. read() and write() are POSIX compliant system calls; they do not belong to a C library; their presence is not covered by the Standard. Indeed, a Microsoft compiler doesn't provide them.

A compliant C library does provide fread() and fwrite() though.

nezachem 616 Practically a Posting Shark

Second, what does this code equal? I believe it equals 19 but our teacher says it is 20.

Run away from that teacher as fast as you can.

y = 2*y++ + --x;

modifies y twice (by means of postincrement, and by means of assignment) with no sequence point in between. Undefined behaviour, end of story. No answer is correct.

nezachem 616 Practically a Posting Shark

I have to get into the gritty details

I was answering the "how do I know the data" question. Fortunately it is highly irrelevant to the task you have. For a copy-on-write, the only thing you need to know is whether to faulting context is allowed to access the page. Once you decide (according to the policies) that it is, just change permissions and restart the context.

nezachem 616 Practically a Posting Shark

Yes you can (sort of), however it is fairly non-trivial. The last parameter to sa_sigaction is a pointer to ucontext_t of a faulting context. Among other things, it includes uc_mcontext (describing the complete state of the cpu). It in turn contains a gregset array og general purpose registers. Now, gregset[REG_EIP] is an address of the faulting instruction. Analyzing the instruction you can recover a type of access (R/W/E/whatever), width of access (8/16/32/64/... bytes), and with a little more analysis of registers and the addressing mode you'd be able to figure out actual data (if it was write access).

This is pretty much the best you can recover.

PS: REG_EIP is of course x86 specific. If there is ARM (or something else) involved, adjust accordingly.
PPS: This is just a mere outline of what needs to be done. Devil is in details as usual.

nezachem 616 Practically a Posting Shark

You never change the clipboard contents. You only copy the text into some global memory, which has no association with a clipboard. Look at SetClipboardData function.

nezachem 616 Practically a Posting Shark


Secondary issue: speed

In regards to speed, I need to write code that gets the job done as fast as possible. This was the simplest copy function I could think of, but I don't know whether it is the fastest. What is faster, fread/fwrite or getc/putc ? Or is there another standard function that can copy even faster?

The stdio buffers data by the same chunks, so the performance difference between fread and getc is in a number of function calls made. Of course fread would be called less times than getc, but I suppose the speed gain would be infinitesimal, comparing with the actual IO time.

I'm also not sure what the bottleneck is in regards to speed, as an portable drive takes more time to write to than for example internal memory. If I write a function that compresses files before they are copied, would that increase speed? Or would it just slow the read/write process down?

The real bottleneck is in transferring data to and from the peripheral device. You sure want to minimize the amount of data transferred, so yes, compression is a standard way to increase the performance.

nezachem 616 Practically a Posting Shark

Something tells me you are on a Windows system. There is a distinction between a text mode and a binary mode. In the first case the ^Z character does serve as an end-of-file marker. Open your files in a binary mode: pass "rb" as a second argument to fopen. Same goes for writing.