Not sure what you are saying here.
Neither do I. Where does SpecialSum() came from?
Not sure what you are saying here.
Neither do I. Where does SpecialSum() came from?
Waiting for I/O counts as it constitute to time used by processor for waiting
Waiting for IO uses no processor time. The processor is busy running other processes.
I suppose signing the applet may help.
The normal java program and an applet have different privileges. The security manager forbids applet's getLocalHost() to return anything but a loopback address.
> if I understood C-Pointers correctly, I just create a reference to the Memory Area where the msg->rcv.src_ip is stored
Your understanding is correct. However, an addr field may only store a reference. If the msg is transient, you need to create a permanent copy of src_ip, for example,
downstream[1]->addr = malloc(sizeof(struct ip_addr));
*downstream[1]->addr = msg->rcv.src_ip;
As a good exercise implement basic coreutils commands (cat, head, tail, cut, paste, etc) using bash builtins.
Is example built by you, or did it come with the source code? I suspect latter. Try to
rm example; make example
BTW, second rule looks really strange.
Posting makefile may actually help.
The description is fairly vague; if I understand it correctly, you want to match space or a start-of-line, followed by a sequence of anything but a backslash, followed by 'e'. Which translates directly to (^| )[^\\]*e
. For example,
nezachem@home> cat junk
\aaaebb
\aaa bbbe
aaae
aaa
nezachem@home> grep -E '(^| )[^\\]*e' junk
\aaa bbbe
aaae
nezachem@home>
The best way to understand this is to take a pencil and paper, and follow the code step by step. Next, run it under a debugger control.
For execv, the args[0] is a process name. You need to initialize it as
char *args[] = ["chrome", "--user-agent=blah", 0];
The actual value of process name is highly irrelevant, but it must be there.
The sed command seems easy to work with, I googled it but I still do not understand the p at the end (-->200p)
By default sed prints every line it works with. The -n option suppresses this (usually unwanted) behaviour. Now that you've get rid of unwanted lines, you still need to print those you need. That's what a p command is doing.
N-R is a very powerful method. It is easy to implement, it converges fast, it doesn't even need a closed form: it is possible to work directly from the initial equation
X1 = X0 - Y0/f'(X0)
and approximate the derivative numerically.
The problem with N-R is that sometimes it doesn't converge at all. This chapter of a Wiki gives some good examples. A proof of convergence in a given case could be very hard and painful.
First of all, I don't believe you. The code you gave may not possibly produce more than one line of output (because of break at line 15).
That said
-- line 11 means
(a) test "$line" -gt 100
(b) if (a) returns success (exit code 0), execute the command "$line" -lt 200
-- $line is a contents of the line you've just read, not a sequence number. Taking your word that "result is all of the lines", I suspect that your file consists of numbers, one per line, all of them less than 100 (this is the only scenario in which your script may run with no errors).
Of course the right way to achieve your goal is a sed script:
sed -n -e '100,200p'
If you insist on a pure bash with no external utilities, then
# read and ignore first 100 lines:
for ((i=0; i<100; i++)); do read line; done
# read and echo next 100 lines:
for ((i=0; i<100; i++)); do read line; echo $line; done
# That's it
People drink it to only get drunk.
No. A real no. I mean, NO!
There are certain foods which is a crime to consume without vodka. Most Russian appetizers are specifically optimized for it. Make for example a bite-size piece of a Russian dark rye bread topped with spicy herring and green onions.
Try it per se - nothing special. Repeat the experiment, but take an ounce of almost frozen vodka right before. See the difference.
And don't let me even start on soups.
Of course vodka must be right one. Don't even think of drinking Gordon's or Monopolova. Classical Russian brands are pretty good. Gray Goose is good but overpriced. Best one I found so far is Tito's; surprisingly it's made in US. Ketel One comes in second.
I suspect that by "not execute" you mean "crashes before reaching that point".
The reason is that at some point the recursion reaches the leaf node. Such node passes the tree != NULL
, after which you dereference tree->left
, which is NULL (and never tested against).
Yes and no. Of course there is a N-R formula for a logarithm, but it involves calculating an exponent at each iteration; that makes it way less attractive than a square root one.
A log n is a solution of exp(x) = n. Applying the same logic as above, you'd arrive to X1 = X0 + n/exp(X0) - 1
If you have a good exponentiator, you're all right. Otherwise, it may become tricky.
>> you agreed with my original point that you're not supposed to store the password in the database?
I did???
Sorry if I has been unclear in my last post. I reiterate:
When providers keep passwords in the database, they do not violate the security protocol. In fact, they have no other way but keep them.
>> You weren't asking questions trying to learn about it
I was trying to prove that keeping hashes instead of passwords is inherently flawed. For me, the point of this whole exercise was to make you realize it. Sorry if I sounded offensive or unfriendly.
> You'll have to ask an https expert
I sort of am.
> when "bob" is passed from Bob to Alice, Eve cannot grab it
Surely she can. The trick is not to pass "bob" from Bob to Alice. Ever.
> The "password" is "bob". That's the one that never changes. That's the one that Alice needs to safely authenticate. That's what Bob types in to log in ...
Correct
> ... and that's what Alice decrypts on the otehr side
Incorrect. As I say, "bob" never appears on the wire, neither in plaintext, nor encrypted. An authentication protocol works as follows:
1. Bob sends username
2. Alice generates a random challenge and sends to Bob. Then Alice appends Bob's password to the challenge and calculates a one-way hash of the combined string.
3. Bob receives a challenge, appends his password to it and calculates a one-way hash of the combined string.
4. Bob sends the hash to Alice.
5. Alice compares a hash she calculated to the hash Bob sent.
Eve cannot recover Bob's password, nor she can pretend to be Bob. The only thing she may is to deny service by tampering.
After the parties are authenticated, and only then, they may start key exchange.
> Anyway, I'm sure there's a whole bunch of tutorials out there that explain it all much better.
I am afraid it is you who needs reading.
…>> Not a problem at all. ... Alice and Bob can pass those keys in the clear and Eve isn't helped in the slightest by intercepting them.
A problem right here. Eve doesn't passively listen to the conversation. She actively modifies data, pretending for Alice to be Bob, and for Bob to be Alice (this is an essence of a man-in-the-middle). Since by that time the identities are not established, neither Bob nor Alice may find out what's going on.
So, the identities must be proven in advance.
The augmented schemes rely on an asymmetric techniques, which prove an identity by a public/private key pairs. This is essentially different from the password based authentication.
And we are talking about password-based ones, right?
It is a standard logic based on a Newton-Raphson method. Here is how it works:
We are trying to solve an equation
x^2 - n = 0
Given an iteration X0, the next iteration X1 is an x-intercept of a tangential at X0. In a general form the tangential is
(y - Y0)/(x - X0) = f'(X0)
In our case Y0 is X0^2 - n and f' is 2*X0, that is
(y - X0^2 + n)/(x - X0) = 2*X0
For x-intercept, y is 0:
(-X0^2 + n)/(x - X0) = 2 * X0
or
n - X0^2 = 2*x*X0 - 2*X0^2
or
x = (X0 + n/X0)/2
which is your formula.
Do I understand your protocol correctly?
1. Since Alice doesn't have Bob's password, yet she needs it to establish Bob's identity, the password must travel across the wire.
2. This password may not travel in clear. Moreover, the encryption key must be session specific (if it is reused, Eve can simply reuse the encrypted password).
3. Alice and Bob have to exchange session keys before their identities are mutually established.
If so, this is a classical invite to a man-in-the-middle.
>> Cool. That is, these keys have no relation to Bob's identity, right?
Correct. They are passwords by however the passwords are created, but specifically NOT created by Bob or Alice. They are created on Bob's computer and Alice's computer and "exchanged". Alice would have a public key and an SSL certificate somewhere. One thing for sure, the password would not be "bob", which is the password that Bob typed in when registering with Daniweb/Alice.
I am afraid that you are missing an important point. It does not matter if Bob played an active role in a password creation. What matters is that Alice must map Bob's something to Bob's personality.
>> You must realize that in this scheme Eve doesn't need to decrypt anything.
Yes, she does. What's sent over the wire is "afsdhjasd;jkflhsdajklr" or some junk like that. If Eve doesn't decrypt that she's out of luck. If SHE tries to send that, it won't work because "afsdhjasd;jkflhsdajklr" works once and only once.
Now I am missing something. How does Alice derive Bob's identity from "afsdhjasd;jkflhsdajklr"?
In particular,
- how this string was created at the Bob's side
- what Alice is going to do with it
It's much more elaborate than that. There are "keys", not passwords, and it's some sort of Diffie-Hellman type protocol. It's one of things with secret keys and shared keys and they're multiplied together, yadda yadda. It's completely different from a log-in password like "bob". It's a …
>> with what key?
Encrypted via the https method. I'm not very familiar with that protocol, but the keys use to encrypt and decrypt will have no relation to "bob" or its hash.
Cool. That is, these keys have no relation to Bob's identity, right?
>> Eve doesn't need to know "bob": she only needs to know what is sent over the wire.
If Eve can decrypt what's going over the wire, then she wins, particularly if "bob" is sent rather than the hash of "bob". I have no idea how hard that is, but I assume it's really hard or we wouldn't still be using https. If she intercepts the hash instead of the password, she's still OK since that must mean that everything's hashed on Bob's end and if there's nothing more sophisticated, she can log in with the hash.
You must realize that in this scheme Eve doesn't need to decrypt anything. She doesn't need to know "bob". Hear goal is not to recover Bob's password. Her goal is to impersonate Bob.
But it'll usually be something more sophisticated than simply sending the hash by itself for just that reason. The server side is going to be doing something mathematically in additional. I'm not real clear on how that all works. But the stuff over the wire is encrypted by a non-hashing method, so if Eve is sniffing, all she gets is gobbledy-gook.
Yes. The stuff which goes over the wire is encrypted with …
Not so fast.
> which gets encrypted on his computer
with what key?
> then is decrypted
with what key?
> A more elaborate version is that it gets hashed AND encrypted on Bob's side, then unencrypted on Alice's side so Alice's side never ever sees "bob"
For me it means that the hash is a password; the fact that it hashes "bob" is irrelevant. Eve doesn't need to know "bob": she only needs to know what is sent over the wire.
A nice way to not answer the question. So, how does Bob log in?
Can you outline an authentication protocol based on one-way hashes?
There is one major design flaw here. Player shall just make a guess. The decision on the guess correctness does not belong to Player; it belongs to GuessGame itself.
I am not sure what kind of trouble you have. Handler id is an opaque value returned when the signal was connected:
id = gtk_signal_connect(obj, name, func, data);
...
gtk_signal_disconnect(obj, id);
You have few problems here. First and foremost, the loop at lines 44-46 does not shift a queue, but rather replicates the leading element. You need to run the loop in other direction, that is shift the last element, then one before last, etc.
Funny enough, the typo at line 41 (I presume you intended *numberOfQueues there) proves that the whole if/else combination is bogus; the control always goes to the else clause. Special-casing 0 is indeed unnecessary.
> What do you mean by that?
Consider the position:
W: Ke1, Rg1, Nf2
B: Kg8, Bg3
Is 1. Nd1 valid?. It passes the "geometrical validity" test, but makes possible 1. ... Bxe1 - the white King becomes exposed even though the Bishop is pinned. In your logic however, you would try to validate 1. ... Bxe1 all the way.
> How else can I do this though WITHOUT using IsValidMove or CanPieceBeTakenByEnemy?
As I said, IsSquareExposed() method is a way to go. Something along the lines of
IsValidMove(from, to)
{
if(!IsPathOk(from, to))
return False();
PretendDoMove(from, to);
if(IsSquareExposed(kingSquare))
return False;
return True;
}
IsSquareExposed(square)
{
for_all_opponent_pieces(p) {
if(IsPathOk(p, square))
return True;
return False;
}
checking if the king can be taken by an enemy piece
... shall not be tested for pins. You need a separate method to test for square exposure (instead of generic CanOtherPieceBeTakenAfterPieceMoving).
Good for you. Gdb is a way to go.
Your problem is that you equate a 2-dimensional array to a double indirection. They are different creatures. That's why the compiler warned you, so that you ended up with explicit cast on lines 197 and 199.
When your function sees a char ** list
, it expects (loosely speaking) an array of pointers: list[x]
must be a pointer. Of course it is not, because the original array does not contain any. With its declaration in scope (that is knowing the row width), the compiler is able to figure out where each row starts.
In a format
function this information is lost.
A solution, instead of fooling the compiler with casts, is to declare your true intentions:
void format(char lines[][MAX], count)
and happily get rid of casts.
>well-documented
As a matter of fact, it is. See a link in my post. As for applications working correctly, MSDN specifies that
For a specified hook type, thread hooks are called first, then global hooks. which means that an application is still able to receive all events, and also warns that
The global hooks are a shared resource, and installing one affects all applications in the same desktop as the calling thread. ... Global hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove its hook procedure.
> Bit 31 in lparam tells whether a key is down.
What gives you such idea?
Try an experiment: set a breakpoint at line 6. Press buttons few times. Pay attention to lparam. Be surprised that it doesn't change. Then read documentation, and realize that lParam is a pointer is disguise, and that wParam is press/release info.
Your programs work fine (you may observe that by decreasing an usleep() timeout to a reasonable value). The problem is that a pipeline IO is fully buffered, and for n
to obtain any input, m
shall produce 4K of data.
Be patient... data will come... slowly...
They are the most efficient I could possibly make them. Any more efficient and i'd have to write it in assembly.
To begin with, both functions make library calls, which are totally uncalled for. A standard technique here is
while(*in_BinaryString)
Result = (Result << 1) | (*in_BinaryString++ == '1')
The IntToBinary (which BTW fails for a negative argument) instead of calling memmove should just return Result + t;
. Since Result is static, its last byte is initialized to 0 and shall never be touched:
char * IntToBinary(unsigned int in_Integer)
{
static char Result[MaxLen];
static char digits = { '0', '1' };
char * dst;
for(dst = Result + MaxLen - 1; in_Integer > 0; in_Integer >>= 1)
*--dst = digits[in_Integer & 1];
return dst;
}
I do prefer a digits array to a ternary for a reason of branch elimination. Assuming an ASCII code set, one may even do
*--dst = '0' + (in_Integer & 1);
In Ubuntu, for example, you can do something like:
sudo apt-get install g++
Don't forget sudo apt-get install build-essential
Upon expanding $(SHELLVAR}, the awk invocation becomes
awk -v awkvar=No error '{print awkvar}'
That is awkvar
is set to No, error
is considered a program (and it is a valid program, a pattern without the action), and the rest becomes a filename to be processed.
Quoting ( awkvar="${SHELLVAR}"
) should help.
I suspect the OP problem is much simpler; it is a purely logical error. Opon the first loop completion, classInfo is the value of the last qualifying trainClassInfo. The second loop always runs all the way through, and the last comparison always evaluates to True.
Solution: exit the second loop as soon as the mismatch is detected.
At the command prompt, typing flex something.l
gives you lex.yy.c file. Similarly, bison something.y
generates yy.tab.c and yy.tab.h files. You may or may not write another C file with main() calling yyparse - inspect something.y for a presence of suitable main(). Assuming it is already there (and assuming gcc as a compiler), type
gcc -o executable yy.tab.c lex.yy.c
. How to integrate it into Java, I have less clue than you.
PS: of course, you need flex and bison executables.
Pascal and C deetct end-of-file in a different way. Not getting into details, a while(!feof())
idiom is unsafe in C. A correct way to read a file is while(fgets() != 0)
flex and bison generate C code from their respective sources (.l and .y). You have to compile them and link resulting objects with the rest of your application. At some point the application calls yyparse() (which is the entry point to the parser).
If you have more specific question, please elaborate.
.wav takes a little more than shoveling it onto a sound card. A starter overview is here, for example.
So, what you need to do is to read and validate the chunk descriptor; read a subchunk 1, which gives you, among other things, a "byte rate"; multiply the byte rate by the number of seconds, and read that amount of bytes from the data subchunk. All of that assuming PCM data.
Most likely. The code is based on a fairly old kernel, but AFAIK not much has been changed since then.
A google search on alsa api returns many useful links. I am not familiar with Windows/C# audio model, so I don't know how well it is mapped onto alsa.
Regarding joystick, it is seen by the system as a serial device; you need to open it, query it with some ioctls (JSIOCGAXES and JSIOCGBUTTONS), and then just read struct js_event (see linux/joystick.h for reference).
> when I have a file that I am trying to convert line by line
You need two passes. At pass 1, when a forward jump is encountered, create a relocation record of branch location and a target symbol. Also during the first pass build a symbol table (a map of labels to addresses). In the second pass, go over the relocation records and resolve them.
There are other techniques, but all of them require two passes.
PS: please use punctuation and capitalization. Your posts are almost impossible to read.
There's no boolean in C. Any incarnation of zero resolves to false; everything else resolves to true. !fork()
is therefore synonymous to fork() == 0
How do you run this program?