gusano79 247 Posting Shark

Those are x86 instructions, and judging from the directives and comments, you could probably compile this code with GAS.

gusano79 247 Posting Shark

Sorry it took me so ling... What you gave me was exactly what I needed, but, vb.net gives me an error because of the quotation mark in the regular expression... Could you please fix that? Much appreciated.

You should do some reading on the String data type:

If you must include a quotation mark as one of the characters in the string, you use two contiguous quotation marks ("").

It looks like this: "href=(['""])(?!.+://)(?<url>.+?)\1"

gusano79 247 Posting Shark

undefined reference indicates that the compilation is fine, but the linking is not. Check which libraries you need to link against. Linking just against glut32.lib is not enough.

Normally you'd need opengl32 , glu32 , and glut32 .

gusano79 247 Posting Shark
gusano79 247 Posting Shark

Ya, I ended up doing just that, and it seems to be working fine. Still kind of curious as to why my first implementation did't work, but whatever. Thanks for looking it over! If anyone wants the updated code with first as a pointer, let me know.

I didn't spend too much time diagnosing exactly where the problem was, but I'm 99% confident that it has to do with the fact that the non-pointers are getting passed by value, so you're making copies instead of referring to the original objects.

gusano79 247 Posting Shark

It looks like we're talking about Unicode canonicalization here... so the canonical form may depend on the encoding used.

gusano79 247 Posting Shark

I see that you're using pointers to entry in some places, and not others... change your code so it's consistent, i.e. use entry* everywhere in your Queue and related classes.

I tested this, and your code returns the following when it's all pointers:

c
b
a

gusano79 247 Posting Shark

A template class won't quite do it because the 'fly' and 'speed up' functions have different names in each struct... you can't write a single template that knows how to call the different methods of each airplane; you'd need a common interface for the airplanes, your lack of which is the original problem.

So. If you don't have any control over the original structures, then I think you're on the right track with creating an interface and a bunch of wrappers. You don't need a macro if you don't mind defining the classes by hand. Since we don't have your code here, I don't know if this is anything like what you tried, so here's an example in case it's useful:

#include <iostream>

using namespace std;

struct airplane_A
{
    void fly_A() { cout << "Airplane A FLY!" << endl; }
    void speed_up_A() { cout << "Airplane A SPEED!" << endl; }
};

struct airplane_B
{
    void fly_B() { cout << "Airplane B FLY!" << endl; }
    void speed_up_B() { cout << "Airplane B SPEED!" << endl; }
};

class Airplane
{
public:
    virtual void fly() = 0;
    virtual void speedUp() = 0;
};

class AirplaneA : public Airplane
{
public:
    void fly() { plane.fly_A(); }
    void speedUp() { plane.speed_up_A(); }

private:
    airplane_A plane;
};

class AirplaneB : public Airplane
{
public:
    void fly() { plane.fly_B(); }
    void speedUp() { plane.speed_up_B(); }

private:
    airplane_B plane;
};

void testPlane(Airplane* p)
{
    p->fly();
    p->speedUp();
}

int main()
{
    Airplane* a = …
gusano79 247 Posting Shark

Also you appear to have an extra ) here:

if (guessedword.equals(word)) {System.out.println(win)[B][U])[/U][/B];}
gusano79 247 Posting Shark

My problem is I don't know how to write the code to detect the Mouse Idle time for two seconds and perform a double-click to highlight the text. the rest I can do. I just want to know how can I recognize the mouse IDLE time and assign a double click to it.

You can use the MouseHover event to detect the mouse being idle over a control.

If your control is some sort of text box, the GetCharIndexFromPosition method can tell you where in the text the mouse is when the MouseHover event happens.

I don't know of any automatic way to find the extents of the entire word given a single text index, but it shouldn't be too hard to scan in both directions from the character index to find non-word characters.

Then you can use the Select method (again, assuming some sort of text box) to actually select the word once you have the character indices of the start and end of the word.

gusano79 247 Posting Shark

I'm attempting to run a few Subversion commands on the command line of WinXP, but it keeps telling me: " 'svn' is not recognized as an internal or external command, operable program or batch file"


I'm pretty new to SVN, so I don't know why its not working. Obviously there's something that I'm missing in order to get these to work.


Thanks!

You just need to set your PATH environment variable to include wherever SVN is installed. For example, C:\Program Files\Subversion\bin --but substitute wherever your 'bin' folder is.

gusano79 247 Posting Shark

OCR is image processing (biomatric application)

Quick note: OCR is not biometric--it's for recognizing writing, not people.

gusano79 247 Posting Shark

I see *it->first , but later on you have *it.second ; they can't both be right. It's a set of pointers to pairs, try *it->second .

gusano79 247 Posting Shark

Is Optical Character Recognition a good example/application of Data Mining techniques ?
or
Should Data Mining be applied mainly to web research/web tools ???

Could you please give me more examples on Data Mining that could make a good project if OCR is not good ??!!

Thanks ! :)

OCR isn't data mining. OCR is for recognizing known patterns; data mining is for finding new patterns.

You could have a Web site front end to a data mining application, but data mining isn't about the Web--it's about databases, pattern recognition, and statistical techniques.

For project ideas, see http://en.wikipedia.org/wiki/Data_mining#Notable_uses.

gusano79 247 Posting Shark

I'm with SasseMan; learning OpenGL will allow you to target a much wider variety of platforms.

Something to be aware of: OpenGL only handles the graphics. It doesn't specify how you create a basic window, or if there is even a window involved. You'll still have to rely on OS-specific code to create what OpenGL calls a context. Once you have an OpenGL context, basic drawing is pretty straightforward. I don't know what problems you had with Visual Studio, but I wouldn't be surprised if most of them were related to creating the context.

Some libraries that can create OpenGL contexts for you on a variety of operating systems are freeglut and GLFW. Both of these libraries also handle user input from the keyboard, mouse, and joysticks. If you're using these or one like them, they don't include sound, so you might consider OpenAL, an API for 3D audio.

Another alternative to all of the above is SDL, which covers graphics, input, and audio all together.

gusano79 247 Posting Shark

Well, in the end it all boils down to pixels on a screen of course.
But with the advent of truetype fonts, the discrete handling(with integers) was not sufficient, hence the use of float.
You could perhaps read this article.

It's not just for vector fonts; GDI+ as represented by the Graphics class does a lot more than twiddle pixels. It's also meant for printing and displaying to a variety of devices. To support drawing to a wider range of devices, GDI+ uses a few different but related coordinate spaces that allow you to easily rotate, scale, and translate your graphics in two dimensions.

OpenGL uses floating point coordinates for similar reasons.

gusano79 247 Posting Shark

Hi
are these two instructions valid in assembly language?
(8086 mov instruction).

1. mov DS,[BX]
2. mov DS,[3900H]

if no,why not?!

They are. MOV SREG, memory is allowed; you can easily look this up yourself. If you need an assembler, try nasm.

gusano79 247 Posting Shark

I forgot to mention that I have all of this in a while loop saying
while (true) {
switch()....

}
}

So when I put your solution in and a non integer is typed in, it keeps printing the same thing over and over again since its looping over again and again

Why do you need the while(true) ? Is it just there to re-ask if they don't enter an integer, or is there some other reason you need that loop?

gusano79 247 Posting Shark

Ok, here's basically how my switch case works...

while (true) {
         System.out.println("Enter a number");
         int i = scan.nextInt();
         switch (i) {
            case 1: 
               String employee = scan.next();
               System.out.println(employee.alljobs);
               break;
            case 2: 
               String job = scan.next();
               System.out.println(job.allemployees);
               break;
         } 
      }

I was going to suggest that you read a string instead, then test it to see if it's an integer and take appropriate action based on that test, but I forgot that the Java library handles that by throwing exceptions itself... :/

The exception way:

System.out.println("Enter a number");
try
{
    int i = scan.nextInt();
    switch (i) {
        case 1: 
            String employee = scan.next();
            System.out.println(employee.alljobs);
            break;
        case 2: 
            String job = scan.next();
            System.out.println(job.allemployees);
            break;
    }
}
catch(InputMismatchException) {
    System.out.println("Please enter an integer");
}

Using Integer.parseInt would look very much the same.

I prefer to only use exceptions for truly unexpected input, and I wouldn't classify non-integer input here as 'exceptional'--users enter all sorts of weirdness.

If you'd like to try it without exceptions, you can read a string and use a regular expression to see if every character in the string is a digit, and optionally detect a +/- sign at the front. I'm not sure that this is necessarily better, though, in terms of readability.

gusano79 247 Posting Shark

I'm not that familiar with MIPS... add comments explaining what you're doing, and I can tell you if you're on the right track.

gusano79 247 Posting Shark

i want to output the total percent of the correction

The first thing you're missing is that somewhere you need to count the number of correct guesses and the total number of guesses.

gusano79 247 Posting Shark
gusano79 247 Posting Shark

What output are you expecting, and what are you actually getting?

On quick inspection, you're using integers for HEAD and TAIL , which is probably making it consistently display '0 percent'. Try casting one of them to a floating-point value, for example: (((double)HEAD/TAIL)*100)

gusano79 247 Posting Shark

In general, using exceptions isn't an appropriate approach to this kind of situation. Please post your code; it will help us help you.

gusano79 247 Posting Shark
gusano79 247 Posting Shark

Here's a quick reference on getting OpenGL to do 2D cleanly.

gusano79 247 Posting Shark

Here's a more general-purpose regular expression: href=(['"])(?!.+://)(?<url>.+?)\1 It finds hrefs to relative URLs; from your example, they seem to be what you're looking for.

gusano79 247 Posting Shark

Oh right.

Also, instead of this:

for (int i = 0; i < noOfMunchies - 1; i++)
{
    for (int j = i; j < noOfMunchies; j++)
    {
        if (i != j)
        {
            // ...
        }
    }
}

You can do this:

for (int i = 0; i < noOfMunchies - 1; i++)
{
    for (int j = [B]i + 1[/B]; j < noOfMunchies; j++)
    {
        // ...
    }
}

Saves you time in the inner loop.

gusano79 247 Posting Shark

Anyone know of a way to obtain an MD5 checksum of a file (through HTTP) before downloading it through HTTP?

Only one way that I'm aware of: Request the file using a HEAD request instead of GET --the server should only return the HTTP headers for the file. One of the possible headers is Content-MD5 , which is a base64-encoded MD5 hash of the content. I say "possible" because it's entirely up to the server which headers it returns. If a server provides it, great; if not, you're out of luck.

pseudorandom21 commented: tyvm +9
gusano79 247 Posting Shark

That's a mess. Please post separate code files in separate blocks, or attach the individual files.

gusano79 247 Posting Shark

I don't know PIC assembly, but this pseudocode should do something like what you want:

If INPUT == 0
  Set OUTPUT = 0
Else
  BARS = INPUT shifted right 5 bits
  OUTPUT = 11111110b
  Shift OUTPUT left BARS times
  OUTPUT = OUTPUT xor 11111111b

Note that the only input value that results in the output bar being completely off is 0, so if it reports any acceleration at all, you'll see at least one LED lit. Whether this is a feature or a bug is up to you. :)

gusano79 247 Posting Shark

Which member function is the compiler complaining about?

gusano79 247 Posting Shark
gusano79 247 Posting Shark

heey I need ur help..
how to convert a string (text content) to base 64 ??what are the steps for writing this program

  1. base64 encodes sequences of bytes, so first you need to convert your string to bytes. How you do this depends on the language/platform you're using... if you're doing this in assembly, your text might already use a single-byte encoding.
  2. RFC 4648 describes how to encode a sequence of bytes as base64. This should be all you need to create your own implementation.

Have a go at writing it yourself, and if you have any trouble, please post your code and questions.

gusano79 247 Posting Shark

I read about the problem and it says I have to verify that the calling conventions I am using are the same. Well, I'm not using any so what's the deal?

The unmanaged DLL is using a calling convention, though. To get it right, you need to know how the DLL was compiled--for example, DLLs written in C typically use the "cdecl" calling convention.

What do you know about the DLL you're using?

The thing is, if I hit "Continue", the code executes fine until the next function return (the first time it's for GetDistance and the second time is for InitLocation). So I don't get it.

That's expected; any unmanaged call that doesn't use the right calling convention will do this. Apart from the exceptions, things might be working for you now, but it could cause mysterious bugs to show up later.

gusano79 247 Posting Shark

The problem file, grade.h.gch , is a GCC precompiled header. Did this file come with the example code? If it did, try deleting it and compiling again.

gusano79 247 Posting Shark

Ok sorry after some readin here's more:
There are things in an os that open the console window n stuff (Stubs?)
I want to make a portable app (have a painfully handcoded way to tell what os the person has at runtime.)
Is there a way to stuff these things into the exe?

Not like I think you mean. Operating systems all have various approaches to the low-level details (ABI) and the system-provided functions (API), which generally means you have to compile your code separately for each platform you want to target.

gusano79 247 Posting Shark

I've just tried that, and I have tried a variation of that in previous attempts; it just seems to keep the munchies constantly re-spawning at the top of the screen as if they're constantly colliding with one another... =S

Can you post the new code?

gusano79 247 Posting Shark

I have an array of enemies (munchies) and trying to stop them spawning on top of each other is proving difficult (They re-spawn in a random x and y coordinate):

for (int i = 0; i < noOfMunchies; i++)
                    if (CollisionCheck(munchiePos[i].X, munchiePos[i].Y, munchieSize, munchieSize, munchiePos[i].X, munchiePos[i].Y, munchieSize, munchieSize))
                    {
                        // change the position of the munchie that collided
                        munchiePos[i].X = Math.Max(0, rand.Next(gameWidth) - munchieSize);
                        munchiePos[i].Y = Math.Max(-500, rand.Next(gameHeight) - gameHeight);
                    }
                }

I understand the problem, it's just checking a collision with the munchie at position i, with the same munchie at position i... but I don't understand how to fix it :/
Thank you to anyone who can help, i'm truly stuck T_T

If you want to check for collisions between munchies, one way to do it is to use two loops, along these lines:

for(int i = 0; i < noOfMunchies - 1; i++)
{
    for(int j = i; j < noOfMunchies; j++)
    {
        // Check for collision between munchies i and j here.
    }
}

This is a very simple, inefficient technique, but it serves to illustrate a point: One loop isn't enough to detect all of the collisions.

If you use this method or something like it, beware of modifying positions during the loop. The safe way to do it would be to only modify the munchie at position j , and in such a way that it can't collide with any of the munchies at positions 0..j-1 .

You also might look …

gusano79 247 Posting Shark

I have a set of assembly instructions that I am trying to assemble with nasm and execute however I am receiving errors and i am not sure why.

Please post the errors as well as the code; this will help us help you.

gusano79 247 Posting Shark

How do you run a profiler?

Depends on which one you use--profilers work in a variety of different ways. Search the Internet for "C profiler" or something similar and have a look at what's available.

If you use an IDE, it may provide some integration already--for example, Code::Blocks has a plugin that runs gprof.

gusano79 247 Posting Shark

thanks for your help charlybones

im having a problem with the part before now

string stem = null;
            String EmQuery = "SELECT [Email] FROM Accounts WHERE Email = " + tbemail.Text + ""; // adds query to "EmQuery"
            OleDbCommand command = new OleDbCommand(EmQuery, AccConn);
            OleDbDataAdapter AdAcc = new OleDbDataAdapter(EmQuery, AccConn); // runs the query
            if (AdAcc == null)
            {
                i = false;
            }
            else
            {
// run rest of code

if i is false a dialog message shows up saying "email not registered"

You don't seem to understand how data adapters work.

Consider this line:

OleDbDataAdapter AdAcc = new OleDbDataAdapter(EmQuery, AccConn); // runs the query

This doesn't run the query. All it does is construct the OleDbDataAdapter object, which in this case initializes the SelectCommand property of the adapter for later use by its Fill method.

Constructors don't return null, either, so the code for if (AdAcc == null) should never actually happen.

Another issue:

DataTable dtacc = AccDS.Tables["Password"]; // puts found password in data table
String PW = dtacc.ToString(); // converts data table to string for validation

This doesn't actually get the password; read the documentation for DataTable.ToString to see what actually happens.

Take some time to read the MSDN section on DataAdapters and DataReaders.

gusano79 247 Posting Shark

Comments are a requirement for any well written program -- complex code is valid as long as equal emphasis is given to its corresponding comments. ... There is no excuse to write bad code, and there is no excuse to write bad comments.

I don't think we disagree; that sounds sane to me. I was more concerned with emphasizing the evils of premature optimization. Complex code is fine; it's just that in practice, you'll have a limited amount of time to spend on any given project, so save it for when it really matters. Also, there are enough people working in software that don't truly understand what they're doing (not referring to anyone here, just a comment on some of the 'professionals' I've encountered), so all else being equal, simpler code is more idiot-proof.

gusano79 247 Posting Shark

To paraphrase, you want your INPUTNXT loop to only consider the last two characters entered, right?

You already have the information you need to find where those two characters start within NUMFLD : The user entered ACTLEN out of MAXLEN possible characters, so there are ( MAXLEN - ACTLEN ) extra characters at the start that you don't care about. Rather than start converting characters at NUMFLD , use that value as your starting offset.

gusano79 247 Posting Shark

The magic word I don't see anyone using here is "logarithm."

From the Wikipedia article, a little below where I linked it:

log10(x) is related to the number of decimal digits of a positive integer x: the number of digits is the smallest integer strictly bigger than log10(x).

Once you know the number of digits, you can start at the largest one and work your way down.

gusano79 247 Posting Shark

The first step in optimizing is to ask yourself, "do I really need to optimize this?" I see "Kernels to be optimized for the CS:APP Performance Lab" in your comments, so I'm assuming the answer here is "yes." :)

In the wild, though, the answer is just as likely to be "no." I prefer to see people write inefficient code that is easy to read and understand rather than a clever, efficient algorithm that is inaccessible to the average coder. The answer becomes "yes" when you can demonstrate a clear, quantifiable need for efficiency.

The second step is to ask yourself, "what should I be optimizing?" The code you posted is short enough that you might answer that question analytically, i.e., read the code and try to find parts that look like they might be slow. If this exercise is supposed to be analytical, then I recommend you look very closely at naive_rotate and naive_smooth --the word "naive" is usually an obvious marker of inefficiency. Do as N1GHTS suggests and rewrite those functions in plain English to understand what they're actually doing. I suspect that the code inside the inner loops can be simplified, and you may be able to shorten or even eliminate the inner loops themselves.

In the field, you'll want to measure an inefficient program to see where the performance-critical areas are. The last thing you want is to spend a lot of time making a particular function run blindingly fast only …

gusano79 247 Posting Shark

the code is ment to look in a directory for .obj files and then read those .obj files for the characters of v and any non character symbol like .30493093 then write to a text file for every v character match write characters of gl_vertex3f I also want it too write out the non character symbols to the text file thats about it but this seems to not be the case

Do you have a short .obj file that you can post here? It helps to have an example to work from.

gusano79 247 Posting Shark

would you be able to rewrite the code so that so it works fully

I don't know what your code is ultimately supposed to do, and I don't have a sample "test.txt" file to work on, so I can't guarantee that anything I write here will work.

so i can learn it will work so i can understand it better ?

I believe all of the pieces you need are here, but you seem to be having trouble with how they all work together. Compare the following code with the previous examples, and hopefully that will help. If you have any questions about why it's written the way it is, please ask.

require "lfs"

input = io.open("test.txt","w")

for entry in lfs.dir("test folder") do
    if string.match(entry, "\.obj$") ~= nil then
		local file = io.open(entry, "r")

		for line in file:lines() do
			if string.match(line, "v") then
				input:write(" GL_Vertex3f ")
			end
		end

		file:close()
    end
end

input.close()
gusano79 247 Posting Shark

Hi guys
i'm trying to just do a simple email/password validation on two text boxes.
This code runs but when i type in a correct email address it throws an error "Object reference not set to an instance of an object." on AdAcc.InsertCommand.Connection = OleAcc;

This is happening because AdAcc.InsertCommand is null. You need to create a new OleDbCommand and assign it to AdAcc.InsertCommand. The linked MSDN page has an example.

gusano79 247 Posting Shark

The addresses returned by gethostbyname are arrays of bytes, not 64-bit integers. The conversion business is just about network byte order... all this means is the most significant byte (i.e., the first part of the IPv4 address) is the first byte in the sequence.

Consider this:

  • 3232235876
  • 0xC0A80164
  • (0xC0, 0xA8, 0x01, 0x64)
  • (192, 168, 1, 100)
  • 192.168.1.100