Click here to Skip to main content
15,076,130 members

Comments by Graham Breach (Top 92 by date)

Graham Breach 31-Dec-14 15:41pm View
The compiler can reorder instructions for optimization. I can't seem to find a decent reference that says that, but the /O0 and /O1 flags to FXC disable instruction reordering:
Graham Breach 31-Dec-14 13:10pm View
I'll add my guesswork: It looks like dist2 might not always be set to a value, so your code might be failing at the imgcolor.g assignment. Since shader code doesn't necessarily execute in the order that it is written, that might be preventing the imgcolor.r assignment too.

There are a lot of "might"s in that, but I hope it helps. You could also try using clamp() instead of min(max()) too.
Graham Breach 22-Dec-14 4:06am View
Using "\r\n" as a delimiter you can split it into lines - I've updated my answer with the extra line of code.
Graham Breach 20-Dec-14 9:09am View
You could use file_get_contents() to read in the whole file as a string, then split the string into lines using preg_split() or explode().
Graham Breach 29-Jul-14 7:29am View
I'm sure you're right about it being a size_t in the end, but the header file has it returning a size_type member typedef. I was trying to keep my answer simple, my thinking being that "declare i and j as vector<int>::size_type instead of int" could have caused even more confusion!
Graham Breach 26-Jun-14 6:41am View
Wikipedia says "Turbo C++ 3.0 was released in 1991" so I would guess not.
Graham Breach 4-May-14 5:20am View
Your question is unclear - do you mean the email address, or the content of the email itself?
In either case, there are RFCs that describe the correct format for content.
Graham Breach 15-Apr-14 2:57am View
I think you meant "or" instead of "and"...
Graham Breach 19-Feb-14 13:02pm View
There is a return 1; in your loop - if you hit that, the printf will not be reached.
Graham Breach 7-Feb-14 9:38am View
You should read the documentation for the web server that you intend to run it on.
Graham Breach 27-Jan-14 9:19am View
You can't know that - you also won't know if the user saved the printout as a PDF, or if the print job doesn't make it to the printer, or if the printer jams or is out of ink.
Graham Breach 23-Jan-14 14:30pm View
I've tried out your jQuery code on a test page, and it works for me - the table cell ID is being passed into the PHP file in the POST data.
Graham Breach 23-Jan-14 6:20am View
I just pasted the line into the Javascript console, then used regex.exec() to test a couple of strings.

Are you sure this is being executed as Javascript, and not on the server?
Graham Breach 23-Jan-14 6:10am View
I've tried your regex in Chrome, Firefox and IE, and all three browsers are happy with it. Where did the error message come from?
Graham Breach 21-Jan-14 5:01am View
Shared libraries on Linux have the .so extension - if you search the web, you should find plenty of information about creating them.
Graham Breach 12-Dec-13 7:46am View
I think you have posted this question in the wrong place. If you're talking about an article on Code Project, there should be a section at the bottom of the article page for posting your comments and queries.
Graham Breach 17-Nov-13 15:00pm View
Did you post this as a comment by mistake?
Graham Breach 10-Nov-13 5:03am View
Are you sure the field is called "Expence" and not "Expense"?
Graham Breach 28-Sep-13 5:46am View
That's not a good idea - from the Adsense help pages:

"Please note that clicks on Google ads must result from genuine user interest, and any method that artificially generates clicks or impressions is strictly prohibited by our programme policies."
Graham Breach 23-Sep-13 8:31am View
You should post a new question with the exact problem you are facing - that way people might be able to help you out.
Graham Breach 23-Sep-13 6:44am View
This is not an answer... and this site isn't stack overflow either.
Graham Breach 23-Aug-13 3:54am View
Windows 7 screen savers work in exactly the same way as in earlier versions of Windows.
Graham Breach 3-Aug-13 10:32am View
Call drawImage() multiple times with different X and Y coordinates. I'm not sure why you would have a problem with that.
Graham Breach 27-Jun-13 8:07am View
You should try using mysql_error() again to find out what the error is. From a quick glance at your query, it looks like you are missing a closing ")" at the end of the list of values.
Graham Breach 26-Jun-13 7:51am View
jQuery works fine in Firefox, so your problem must be something else. Are you using the NoScript add-on by any chance?
Graham Breach 21-Jun-13 4:28am View
Javascript's Date class doesn't have a "format" function.
Graham Breach 31-May-13 15:09pm View
I would vote +5 for this comment.
Graham Breach 28-May-13 3:14am View
Are you sure this is MySQL and not Microsoft SQL Server? MySQL uses version numbers like 5.5, but there is a Microsoft SQL Server 2008.
Graham Breach 13-May-13 6:02am View
This smells like homework.
Graham Breach 12-Apr-13 11:11am View
The OP didn't ask for removing trailing spaces, only for replacing double spaces with single.

But if you need that: ctrl.value = s.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '');
Graham Breach 12-Apr-13 7:55am View
Not only would that not work, it adds an extra space at the end.
Graham Breach 9-Apr-13 4:27am View
It looks OK, except you're not waiting for the image to load before drawing with it. "canvas" and "context" should be declared as variables somewhere too.
Graham Breach 6-Apr-13 4:15am View
Can't you just use CSS for this? Use #sf { ... } for the blurred image and #sf:focus { ... } for the focussed one.
Graham Breach 22-Feb-13 4:32am View
Try Google.
Graham Breach 19-Feb-13 18:14pm View
I've added PRE tags around your code to show the indentation. Did you miss off the "d" from "def" when you pasted, or is that the problem?
Graham Breach 31-Jan-13 6:34am View
The code at the top tells you - it's using the "ionCube encoder"
Graham Breach 27-Jan-13 9:31am View
If you want decimal, then I think you can just replace "dollar" with "pound", "cents" with "pence" and "cent" with "penny".
Graham Breach 3-Jan-13 8:52am View
If you can't add server-side code, where are you planning to put the Javascript?
Graham Breach 2-Jan-13 4:30am View
I don't think you can, at least not without asking the user first.
Graham Breach 2-Jan-13 4:16am View
You already asked this yesterday:
Graham Breach 15-Dec-12 19:15pm View
OK, then you can use the timeline view to record events and reload the page. Changes that make the page redraw are listed along with a link to where in the Javascript the update was caused.
Graham Breach 9-Dec-12 7:40am View
No, because you don't initialize the static member variable in the constructor - initialization goes outside of any functions and only runs once.
Graham Breach 9-Dec-12 5:54am View
Then you use the static member variable and increase or decrease its value.
Graham Breach 8-Dec-12 10:57am View
No - the line of code goes outside of any functions, and only initializes the variable once at program start-up.

If you want each instance of the class to have its own number of students, then use a non-static member variable instead and initialize it with the class constructor. Of course you can do both, but you would have to give them different names.

This stuff should be near the start of any decent C++ text book.
Graham Breach 22-Nov-12 7:31am View
I think you have the wrong code for a hit counter. Storing the number of views in the session will tell the user how many page views they personally have had (and only in the current session) and not how many views in total that the site has had.

You need a counter that stores the count in a database or file on the server.
Graham Breach 20-Nov-12 6:06am View
If you really want to do that, you will have to add "./" to your path. Exactly how you do that depends on which shell you are using.

Having to use "./" means that you do not accidentally run files in the current directory, which is a good thing.
Graham Breach 20-Nov-12 5:42am View
This works for me:
cat /home/user1/tmp/*.txt | egrep '^$' | wc -l
Graham Breach 11-Oct-12 9:08am View
Good point - I tend to use "~~variable" for truncating in Javascript and another method I've seen is "variable|0".
Graham Breach 5-Oct-12 4:45am View
Sorry, but I don't have one.
Graham Breach 5-Oct-12 4:45am View
There might be something wrong with your IE9 settings, or your SVG is being sent from the server with an incorrect content-type, or the SVG content is incorrect, or something else that I can't even guess at.
Graham Breach 16-Sep-12 3:43am View
3) I don't know. Read the collapser documentation.
Graham Breach 16-Sep-12 3:42am View
1) Everything has to go inside $(document).ready() because these functions add handlers to the document. If the document has not loaded, then the handlers can't be added.
2) I don't know - you'll have to read the collapser documentation.
Graham Breach 15-Sep-12 15:17pm View
The $(document).ready(function(){ ... }); should go around ALL of the jQuery code. At the moment you have set it to hide the "panel" divs, but the click() and collapser() functions are still outside of the callback function.
Graham Breach 15-Sep-12 6:06am View
You've included the plugin twice again, so that could prevent the rest of the script from working. Apart from that, you're calling the jQuery functions directly in the header before the DOM has loaded, which is too early - you have to use the $(document).ready() callback or something similar.

I suggest you read through the jQuery tutorial before going any further:
Graham Breach 15-Sep-12 5:47am View
Then you should add the correct character encoding in the document or in the transfer protocol.

See for details
Graham Breach 27-Mar-12 7:33am View
You didn't show the jQuery include, so I assumed it wasn't there. Apart from that the code works fine for me (except when I pasted in your "<<- THIS IS NOT GETTING PRINTED ..." as well, which broke it.)

If it wasn't obvious, I normally get questions like this by email because I am the person who made TagCanvas.
Graham Breach 27-Mar-12 5:44am View
If you mean Javascript errors, you should look in the Javascript console (or Error console in Firefox, Developer tools in IE).
Graham Breach 12-Mar-12 11:54am View
If you swapped the order of your divs, then the login div would appear when you hover over the caption. But it would only appear when the mouse was over the caption, not when you try to move the mouse over the login div.

If you put the login div inside the caption div, then change the CSS selector to .caption:hover .loginHolder without the "+", it should work.
Graham Breach 9-Mar-12 12:28pm View
The error is probably because I used double quotes in my answer, and you used double quotes to quote the Javascript in your echo command. Uday's answer shows how to do it more clearly by using single quotes inside the double quotes.
Graham Breach 7-Mar-12 9:39am View
In your example $arr is already a string. What are you trying to do?
Graham Breach 28-Feb-12 5:50am View
You can shuffle them by swapping entries around at random, the same way you would with a pack of cards.

Then you can truncate the array if you need fewer than 25 random numbers in it.
Graham Breach 22-Feb-12 16:55pm View
OK, I stand corrected on the objects not being associative arrays part.

But they still don't support .length - and I did check using the console in Chrome and FireFox:

> var x = [1,2,3]; x.length;
> var x = {a:1,b:2,c:3}; x.length;
Graham Breach 22-Feb-12 16:54pm View
OK, I stand corrected on the objects not being associative arrays part.

But they still don't support .length - and I did check using the console in Chrome and FireFox:

> var x = [1,2,3]; x.length;
> var x = {a:1,b:2,c:3}; x.length;
Graham Breach 17-Feb-12 6:35am View
Did you follow the link I posted? There is an example on the page showing what you have to do.

Try this:
move_uploaded_file($_FILES['file']['tmp_name'], 'C:\\xampp\\FileZillaFTP\\' . $_FILES['file']['name']);
Graham Breach 15-Feb-12 9:03am View
Impressive cut-and-paste skills! (
Graham Breach 10-Jan-12 4:18am View
You're suppressing errors by putting '@' in front of mail(... - take that out and you might be able to see what the problem is.
Graham Breach 6-Jan-12 8:22am View
Either change from using "system" to "exec" and store the result in a variable, or use output buffering (ob_start, ob_get_flush, etc.)
Graham Breach 27-Dec-11 4:52am View
I expect it's a permissions problem, but I've never run PHP on Windows so I don't know what you would have to change to make it work.

I would try adding some logging into the EXE to see if it is failing to write the file or failing to read from the bluetooth device. There may already be some useful messages in the web server logs to help you find the problem.
Graham Breach 23-Dec-11 4:10am View
By "extensible headers" he meant that the TIFF format allows you to add your own data to the format. The 34665 tag you are seeing is actually EXIF data, so if you have an option to support EXIF, you could try turning it on.
Graham Breach 22-Dec-11 15:48pm View
Well... you can't run your EXE directly using Javascript, but that's where AJAX comes in. If you're not familiar with AJAX, I would skip it and just make your PHP page call the EXE and output the result.

Remove your button and replace it with <?php system($cmd); ?>
Graham Breach 22-Dec-11 5:21am View
Go to your FireFox options, under "Content" tab, "Fonts & Colours" section, "Advanced..." button - there is a minimum font size option. If that is set, try changing it to "none" and see if your CSS works then.
Graham Breach 21-Dec-11 6:17am View
Nothing inside that string should cause trouble. Quoting problems happen when you have the same quote marks inside the string as you use to delimit the string.

Example: "They say, "Huh. It Works. It makes sense."" - the inner quotes have to be escaped with a backslash: "They say, \"Huh. It Works. It makes sense.\""
Graham Breach 13-Dec-11 17:04pm View
That's a header file, and it is part of X-windows.
Graham Breach 3-Dec-11 7:52am View
If you do that, you are calling alert("ok") at the time that you add the button. You need to wrap the code you want to call when the button is clicked inside a function:

function clickedFunction()


Graham Breach 3-Nov-11 15:15pm View
No, I'm afraid Google don't say exactly how often they crawl sites, but I believe the more often your site is updated with new content, the more often they will crawl it.
Graham Breach 2-Nov-11 10:17am View
Go to the Project menu, open up the properties dialog, then find Configuration Properties -> C/C++ -> Precompiled Headers and change the "Create/Use ..." option to "Not using precompiled headers".

The better option would be to use a .lib, but that is just slightly more tricky than turning off precompiled headers.
Graham Breach 2-Nov-11 10:02am View
The answer to why is in the error message - you are trying to use a C++ precompiled header from a C file (sqlite3.c)

Either turn off precompiled headers, or create a new project to build a static .lib file from sqlite.c and link to that instead.
Graham Breach 30-Sep-11 6:57am View
Why are you explicitly calling the destructor? That's not something you would normally want to do - the destructor is called automatically when the instance goes out of scope.

If you create an instance of the class using new, then you should delete it using delete.
Graham Breach 30-Sep-11 5:58am View
For template classes and functions, yes.
Graham Breach 13-Sep-11 8:11am View
Then you use an "if" and not a "switch/case".

"switch(true)" - ?????
Graham Breach 5-Jul-11 7:19am View
I've just noticed the question was posted in april... I hope it wasn't urgent...
Graham Breach 10-Jun-11 14:17pm View
Fair enough - this approach is most useful if you can't add ids to the labels, but Ed is right that it can be an awful lot slower when there are a lot of labels to check through.
Graham Breach 26-May-11 10:14am View
I agree - it looks like this code will only work in IE.
Graham Breach 23-May-11 5:09am View
No, in Javascript accessing a non-existent member of an array will give you undefined, but not throw an exception.

var complicatedName as Array; is not valid Javascript either.
Graham Breach 23-May-11 2:04am View
Replaced > and < with &gt; and &lt;
Graham Breach 10-May-11 15:18pm View
If the count is 0, you'll still get one row containing the value 0.
Graham Breach 6-May-11 4:55am View
You haven't said where you are using it, or what is giving you the error. But it is true that the font tag is outdated, and you should use CSS to modify text colours.
Graham Breach 1-May-11 13:22pm View
No, the "void" bit means that the functions don't return values. You should really learn something about the language before you try to modify the code.
Graham Breach 16-Apr-11 13:10pm View
It was better the way you had it originally. Now your global variables for width, height, etc. are not global anymore and are therefore not accessible by the draw functions, and you moved the getElementById out of the init function where it should be.

I just tried your original code in Chrome, replacing init() with window.onload = init, and it works. Are you sure that the Blackberry browser supports drawing on a canvas?
Graham Breach 5-Sep-10 4:00am View
I've updated my answer with the options that I know will work.
Graham Breach 4-Sep-10 5:28am View
I meant server software, it doesn't have to be on another computer. If you are not running any server software, then that is your problem - loading a PHP file from the local filesystem will not make it run.
Graham Breach 15-Jul-10 2:17am View
Reason for my vote of 1
You asked the same question yesterday, and got an answer.