|
I am open to suggestions.
|
|
|
|
|
Here are some:
- unspecified catch = deadly sin
- store actual exception as inner exception in functional exception
- user-generated exceptions should inherit from ApplicationException
- two try blocks where one would suffice
- redundant chTemp initialization
- should use using statement
- char[] chAim = strToDig.ToCharArray(); is redundant; use strToDig[index]
And the algorithm is wrong, as I reported earlier.
|
|
|
|
|
Thanks for the advices. I will change the code accordingly.
This algorithm covers my needs. It works, it is fast and it doesn't consume much RAM.
|
|
|
|
|
Similar to StarBP:
use 2 rolling buffers which are the size of the search terms.
initialize by loading data into buffer 1
repeat the following steps:
clear buffer 2
dump buffer 1 into buffer 2
load fresh data into buffer 1
combine the buffers
search the combination
If the buffers are the correct size your search terms will always be in one combination.
The overhead is that you will be searching each buffer twice though.
hope it helps
Shane
|
|
|
|
|
Dear coders.
If you would not mind taking a look at this page...
http://www.licenturion.com/xp/fully-licensed-wpa.txt
If you see that the installation id is a string of digits, very long... e.g
234344-345656-898909-878766-567676-555655-454334-565556-77 etc
When the check digits are removed, it ends up as a 42 digit number, and this is represented as a byte array encoding of this, 17 bytes long.
How do i get the above long string of digits into its 17 byte representation?
I do not simply want a byte array the same lenght of the string (i.e. 41 digits) I need an actual byte array of 17 digits that represent the numer.
Basacaly, i need to be able to generate the byte array of the string above and vice versa (it may be a base-10 representation.
If no one can help, how can i do the following?
Have a byte array like
BYTE[] = {0x44, 0x34, 0x22, 0x47, 0x49, 0x78, 0x54, 0xf3, 0x2a, 0x44, 0x44, 0x28, 0x44, 0x83,
0x33, 0x22, 0x44}
17 bytes, to represent an encoding of a long number of forty something digits in a string of:
034333-495655-345444-090986-091232 etc....
Basacily as in the text above.
Thank you
Steve
|
|
|
|
|
There may be something in the GMP Bignum Library that can help you. Try searching the Internet for GMP C# bindings.
|
|
|
|
|
Thank you i will try that,
However, there was a simple block of code i found but i cannot find it.
Is there some code that will convert/encode a byte array as a BASE-10 encoding, and one to decode.
I can find many that will encode my byte array to represent base 24, base 32 or HEX but not a string of digits (base 10)
Thank you
Steve
|
|
|
|
|
If I wanted to do this I probably would download the source code mentioned in the document, open up main.c, read it, find that the DecodeInstID function implements the algorithm, and then translate that into C#. Is this what you did, but then forgot?
Alan.
|
|
|
|
|
Yes but it has been so long i have forgot my c and i tried that but cant figure it out.
Steve
|
|
|
|
|
Hello. I have searched for a way to P/Invoke the Graphics.FillPolygon(Brush, Point[]) method. I saw that it is much faster to do so (likely because it bypasses error checking that is unneeded in a well-made program). However, I have not found any examples of how to do so (even .NET Reflector is of no help, only referring me to a P/Invoke that uses a private native field). Please help me translate this code into a P/Invoke. The FillPolygon method is the most important by far, as it is called 10 times more often in the real code as the Clear method is. This Render method takes up an average of 75% of the time in the code, as profiled by NProf (a specially modified version that samples 5x as often as usual was used).
public static void Render(Color color, SolidBrush brush, Point[] points, Graphics graphics)
{
graphics.Clear(color);
graphics.FillPolygon(brush, points);
}
|
|
|
|
|
This is the MSDN page[^] for the Polygon function in gdi32. You need to set the brush and fill mode first and it will draw it filled for you.
[Added]This page[^] gives you the gdi+ function signatures[/Added]
|
|
|
|
|
Thanks, but how do I apply this using C# code? Oh, and what you showed me is normal GDI. System.Graphics uses GDI+. Is this any problem? (I have heard normal GDI is faster, though; is this true?). Here is a slightly modified version of the context within which the code is used:
if (!isPerformanceTest)
{
Renderer.Render(newDrawing , g));
}
bitmapData = bitmap.LockBits(
new Rectangle(0, 0, (int)(Tools.MaxWidth / reduction), (int)(Tools.MaxHeight / reduction)),
ImageLockMode.ReadOnly,
PixelFormat.Format32bppArgb);
I would like some code if at all possible.
|
|
|
|
|
I'd have to work at and test a C# PInvoke method. I have edited the original post with a link to the MSDN GDI+ page[^] with the GdipFillPolygon function signature (gdipluss.dll).
|
|
|
|
|
Here is the complete source code of the program. It may only be used under the provisions of the GPL. This is not Roger Alsing's original work; it has been very highly optimized. Further optimization of other sections is almost useless without optimization of the renderer. I tried Direct3D, which was very good, but it had WAY too many bugs to even attempt to continue on. The Render method is in the Renderer.cs file and is called by FitnessCalculator.cs, which is in turn called by MainForm.cs. The DnaPolygon.cs and DnaDrawing.cs files are used extensively.
Download Source Code
The two lines of the Render method that I mentioned in the original post together take more than 70% of the CPU time of the program.
|
|
|
|
|
Hi,
I am trying to create a web software that will get a URL where is has a long list of links (each link lead to a pge where i want to check a certain filed and get its data), and from that moment on will run alone, using the 'back' option to get back to the previous page where it has the list, then entering the next link and so on.
How can I do that? I know I can cntrol IE but I am not sure if it will be enough...
Thanks for any help ninjas
|
|
|
|
|
You don't need a browser for that, it is much easier using just (Http)WebRequest and (Http)WebResponse, then somewhat parse the HTML page you get.
BTW: Make sure to keep a list of URLs already visited, to prevent running in circles.
|
|
|
|
|
Hi Luc thank you very much for your help!
Will i be able to navigate from that page? As if clicked the 'back' button?
and thanks for the tip with list it will definitely help me saving some time
|
|
|
|
|
There is no need for going back; this is how I make a sniffer:
1. create a list of pages already seen; it starts out empty;
2. create a list of pages to visit; it starts out with a single URL;
3. fetch the first page in ToVisit; remove it from ToVisit and add it to AlreadySeen;
4. parse the page and add all URLs of interest to ToVisit, unless they are already in AlreadySeen;
5. if (ToVisit not empty) goto 3
remarks:
1. one advantage of this approach is it performs a breadth-first traversal, so it is not wandering off right away.
2. of course you must be careful to limit the reach of the sniffer; maybe you don't want to parse pages whose URL don't start with the URL of the very first page (so www.XXX.com will visit and scan www.XXX.com/more but will not dive into www.microsoft.com)
|
|
|
|
|
Thats a great way and I would definitely use it.
What happens when you dont have a list in advance, and you want keep flowing on the list? it is a large list on that page and getting all its url's will be force me to actually get there...
|
|
|
|
|
Sorry, I didn't understand that.
|
|
|
|
|
Hello
My apologies to jump into this thread but I have a very similar question
My goal is more to emulate command on a web page than simply browse the different link from pages to pages
The problem is How to identify command syntax ?
In some case I can use Firebug to see what command is sended and then reuse the command with specific parameters using Csharp and an HttpWebRequest
But Firebug do not always shows the command
Is there any way to "sniff" commands and see exactly what is sended ?
|
|
|
|
|
baranils wrote: Is there any way to "sniff" commands and see exactly what is sended ?
There is no general solution AFAIK. The page could be full of JavaScript, it could calculate whatever it chooses, and then fetch another page from there.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thank you Luc
In my case it should not be too complicate I hope
The control is a dropdown list and I can already get the elements of the drop down in the Html content
The problem is that I can't see what command is sended when the dropdown value changes
What would be a good approach to get it ?
N.B : I do not understand why is some case such commands are shown into firebug and in other case not ?
What can be the difference ?
|
|
|
|
|
it could be as simple as an HTML form with a "dropdown"; the form's action could be a GET (=regular URL will be used) or a POST; the inputs of the form then get appended to the URL. That would really only fetch a new page upon pressing a button.
and it could be almost anything when JavaScript is used, as with an OnClick method, and maybe an OnSelectionChanged method or something similar. I can't tell you more.,
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Thank for your help Luc
I will continue to investigate.
I'm certainly not the first to try to automate a web page and it must be a way anyway to check what the page is sending to get an answer
I can understand that with a WinForm application it is not so easy to trace the event and methods. Anyway a good debugger can do it
I can't believe that it will be more complicate to get the outgoing flow from a web page ?
I will continue to learn about this interesting topic
|
|
|
|