Click here to Skip to main content
14,921,311 members

Comments by Matt T Heffron (Top 200 by date)

Matt T Heffron 3-Mar-18 13:19pm View
Since the OP says "string array", there doesn't seem to be any ambiguity about the problem statement. So, as you said, this solution isn't for this problem.
Matt T Heffron 3-Mar-18 12:52pm View
Nope. HashSet<t>.Contains() is O(1).
Matt T Heffron 21-Feb-18 17:45pm View
To get the counts of each key, without needing the explicit .ContainsKey() test you could use the somewhat obscure class System.Collections.Concurrent.ConcurrentDictionary<TKey,TValue>
In your example changing Dictionary<string,int> to be ConcurrentDictionary<string,int> the whole
if (!myCounter.ContainsKey(atref.TextString)){  myCounter.Add(atref.TextString, 1);}else{  myCounter[atref.TextString] += 1}
collapses to the single statement:
myCounter.AddOrUpdate(atref.TextString, 1, (k,v) => v + 1);
Of course, this comes with the cost of concurrency protection overhead that isn't necessary.
Matt T Heffron 21-Feb-18 17:22pm View
John, Maciej's example had the count of number of duplicates for each key. The .Count property of HashSet is the number of entries in the collection, so it is the number of keys. (Not even the number of keys that have duplicates.)
Matt T Heffron 21-Feb-18 13:36pm View
But a HashSet won't give the count.
It is approximately equivalent to Dictionary<T, bool> but if the key is present the bool value is always true.
(Or am I missing something... ?)
Matt T Heffron 31-Jul-17 16:08pm View
There's also GNU Octave which is a free, open source, Matlab clone (very close). It has many free libraries on Octave Forge
Matt T Heffron 14-Jun-17 18:58pm View
  string period = @"\.";
work even more simply?
Matt T Heffron 13-Jun-17 20:38pm View
The pattern I showed above will give 3 matches for: "String goaway String foo <string>". The first two will match as "return" and the third will match as "return2". If you only want to check for a single "optional" character before the <string>, then change ".*" to ".?"
Matt T Heffron 13-Jun-17 20:32pm View
That's what I suspected, but didn't want to assume. Why not just use 2 different Regex's and see which matches with .IsMatch() ??
Matt T Heffron 13-Jun-17 20:29pm View
Doesn't this do it more simply? " ?(?<return>String) ?|.*<(?<return2>String)> ?" (Your second case is a subset of the first.) Why are you returning the matched "String"? Since you know what it contains, why return it?
Matt T Heffron 17-May-17 12:24pm View
The right tool for the job.
Matt T Heffron 3-May-17 2:18am View
So what's it doing that isn't what you intend/expect?
Matt T Heffron 24-Jan-17 12:45pm View
(I've been "off the grid"...)
In the big picture, I think that each of the two forms have their advantages, and there are some queries that can be expressed only in the method syntax (like the "FirstOrDefault()" above).
For example, (for me) the SQL form is better if there are JOINs.
This is not a point where you should be strict on overall consistency of choice of syntax form.
Use what makes sense in each context.
Matt T Heffron 15-Jan-17 1:05am View
As stated above you cannot mix them in the same address space.
You need to run the 32 bit COM server as a separate process.
(An out-of-proc COM server.)
Long ago I knew the magic incantation to tell COM to run a DLL in a separate process, but those memory cells are not operational. :-)
My recollection was that it was a fairly simple variation to registering the COM server.
COM would run the service in its own process and would do the marshalling between processes.
Matt T Heffron 2-Dec-16 17:17pm View
Re: Tip 0: This is pointless advice.
The string "+" operator compiles into calls to string.Concat() [at least with VS2013, Release mode]
On the other hand, don't use string concatenation (either "+" or string.Concat()) to build up a string piecewise sequentially.
(This will create lots of intermediate string instances that are almost immediately dropped.)
Use a System.Text.StringBuilder in this case.
Matt T Heffron 30-Nov-16 17:50pm View
Also, why is Items string[] when the values are stored in sourceItems which appears to be a collection of AutoCompleteItem (which is not a .NET class, so we have no idea what it is!)
What does SetAutoCompleteItems(...) do? (Show the code)

Use "Improve question" above to edit. (Don't put code in the "Comments". It's very difficult to read there.)
Matt T Heffron 30-Nov-16 17:29pm View
First, figure out why the cmd.ExecuteReader() is failing. The rest of your difficulty doesn't matter until that works.
Matt T Heffron 17-Nov-16 17:56pm View
(For starters, your nested classes declaration looks a bit strange...)
Why are you trying to put the Namespace inside the MainForm?
It is not possible to change the namespace for part of a type (class) declaration. (What would that even mean?)
Matt T Heffron 14-Nov-16 14:51pm View
Actually, the using directive (this is not the using statement) is allowed inside a namespace (but not in a class). See the C# Language Spec, section 9.4.
Matt T Heffron 8-Nov-16 20:38pm View
It isn't clear what you are trying to accomplish.
As shown, there's no point in using Threads at all, since as soon as you start each thread, the Join() will block until the Thread completes. So this just could be all performed straight through in the Main().
The demo class has the locking flag which also accomplishes nothing since it is true and there's nothing that changes that.
Further, it is considered to be a very bad idea for a class instance to lock() itself. A better practice is for the class instance to have a private field of type object that is initialized to a dummy object to be used to lock the access to operations in the class.

Please use the "Improve question" above and clarify what you really are trying to do.
Matt T Heffron 3-Nov-16 14:30pm View
Add it as a Solution so I can "Accept" it!
Thanks again.
Matt T Heffron 3-Nov-16 14:29pm View
That's the trick!
Matt T Heffron 3-Nov-16 14:25pm View
Is the Setter somehow trying to cache the Path as Content and only able to use it in one place?
Is there a way to use the Template property's ControlTemplate in each Style to set the Content of the parent Style?
Is there a way to have a ControlTemplate that is "based on" another ControlTemplate directly to allow setting the Content for "multiple use"?
Matt T Heffron 3-Nov-16 14:17pm View
See my update. It appears it may only work ONCE.
Matt T Heffron 6-Sep-16 12:58pm View
Matt T Heffron 18-Aug-16 13:55pm View
In addition to Richard's advice, I'd add that you probably should enable the debugger to automatically break on exceptions.
That's on the menu: Debug -> Exceptions...
In that dialog, check the "Thrown" column check box for "Common Language Runtime Exceptions"
This will probably give you some false positives (so maybe wait until you're at the last point in running your app before it crashes).
If this doesn't catch it, then you might need to check all of the check boxes!
Matt T Heffron 27-Jul-16 19:24pm View
Sorry, this looks like homework.
You need to do your own homework.
If you really don't understand where to start then you should speak with the instructor (or teaching assistant).

If, you have specific questions with the code you've tried then come back and ask for help.
Matt T Heffron 27-Jul-16 13:13pm View
Besides the fact that the C# wouldn't compile; since IronPython is .NET, why not expose this functionality from a C# assembly (dll) and reference that from the part of your code that is in IronPython? (I've never used IronPython, but I expect that it can reference other .NET assemblies...)
Matt T Heffron 27-Jul-16 12:57pm View
You should not post a Solution to reply to a comment.
You should use the "Have a Question or Comment?" button for basic comments.
That way the person to whom you are responding gets an email notification of your comment.
(Comments do not allow for code markup.)

If you want to add anything more substantial, like explanatory code, then use the "Improve question" that is at the bottom of your original question. Keep the original question intact, but add the addition(s) below.
Matt T Heffron 11-Jul-16 13:59pm View
Further down in that comment OP also stated:
"In the above example result The first two record of SPName,TagName,ecomment values are same but other columns like CurrentValue, ChangeType are different TaskName is same.
In the third Sp2, Tag2, ecmnt2 are different because these members are present in list1 but not in another list2 so i kept the list1 members in the result.

similar way Sp3, Tag3, ecmnt3 are present in list2 not in list2 so i kept the List2 members in the result.

So i need an algorithm to handle the above requirement as shown in the above result."

So, although the lists are sorted, some entries may be present in only one or the other list.
Matt T Heffron 8-Jul-16 17:08pm View
You are correct, the question is ill-stated.
You could answer that the code will not compile because length has not been declared.
It seems most likely that length means the length of myArray (i.e., 8)
Using the answer you gave above would probably be the best strategy.
It shows critical thinking.
Matt T Heffron 8-Jul-16 12:50pm View
While this is good, it seems to be missing the detection of insertions/deletions (entries in only one list or the other) as described in his comment above.
I don't have a solution for that, although with sorted lists I have some thoughts...
Matt T Heffron 7-Jul-16 13:08pm View
So, is the memberimage property of the GroupVM a List<image-type>?
If not, then you don't have the correct data structure to store what you're looking for.
It might be lots simpler to construct this piece-wise. Especially, if these are in-memory instances/collections.
Matt T Heffron 5-Jul-16 14:11pm View
Do you need to do some sort of matching of items between the lists, or are you just comparing them in the order they occur?
You said that the files(lists) are different sizes. Do they match pair-wise until the end where one is longer than the other? Or, do you need to detect extra rows in one (insertions) and then get back in sync?

What part of this is the actual problem?
(The comparison itself is easy, I hope that's not the problem...)
Matt T Heffron 29-Jun-16 18:28pm View
I don't think that does what you think it does.
Both of the systems I'm dealing with already have the "en-US" CultureInfo.
The time zone would be a property of the system clock.
I cannot change the system clock on a per-thread basis!
Matt T Heffron 24-Jun-16 22:18pm View
Even if you fix the Regex as suggested, the example you give will have aA with 3 elements and bA with 4.
What is it that you are really trying to accomplish?
(BTW. All of the .ToString() of the aA[i] and bA[i] are pointless, the values are already strings!)
Matt T Heffron 21-Jun-16 12:03pm View
Marc, This question is a follow up from OP's previous question at and the discussion following my Solution there.
OP's is using the System.Windows.Forms.Control.Invoke to update the UI across threads.
Matt T Heffron 17-Jun-16 16:55pm View
We'd both be better off if you reposted this as a new Question with a good title and description and the code formatted with the <pre ...> tags.
It also makes it easier to find for future folks searching for solving a similar issue.
Matt T Heffron 17-Jun-16 14:49pm View
Actually all you needed was a ; after the } (oops!)
The IOException means that some other process has that file open, probably for writing. Since you are calling this because of a FileWatcher Changed event, you need to wait for a little time after the "last" Changed event to determine if the file is done changing and is "readable". How long depends on how the file is being written.
Matt T Heffron 17-Jun-16 12:41pm View
+5 to counter undeserved 1 vote.
Matt T Heffron 17-Jun-16 12:41pm View
The Cross-thread error is because you are executing this in a different thread from the UI thread. The properties/methods of UI controls must be access from the UI thread. There a property and a method on controls to deal with this.
See my update to the Solution.
If the colorTextbox method (or any method) accesses any UI controls from a thread other than the UI thread then this same error will occur there. You'll need to look for and fix all of these!
Matt T Heffron 16-Jun-16 16:52pm View
Try removing the static from the OnChanged method.
Matt T Heffron 14-Jun-16 17:12pm View
Yes, maybe...That's why I asked for clarification.
It appears that, maybe, group is expected to end up as two dimensions.
Or maybe group is just to end up as 22 concatenated F.*i vectors.
Matt T Heffron 14-Jun-16 12:46pm View
What is it that you are trying to accomplish?
What should group contain afterwards?
Use "Improve question" to describe what it is that you are trying to accomplish.
Matt T Heffron 14-Jun-16 12:33pm View
A partially ordered set with a single ordering predicate that is applied to every pair of elements makes this a totally ordered set.
Wikipedia: Partially ordered set -- Formal definition

That a partially ordered set can have a maximum, does not guarantee that it does. A totally ordered set is guaranteed to have a maximum.
Matt T Heffron 13-Jun-16 17:26pm View
I posted a similar solution a couple of years ago: playing cards game - Solution 3
If avoiding bias in the resultant "shuffles" is important, pay particular attention to the Potential sources of bias in the Wikipedia article. (For example, to have an unbiased shuffling of a 52 card deck the pseudo random number generator must have at least 226 bits of internal state!)
Matt T Heffron 13-Jun-16 17:17pm View
The "other" condition on determining "best" is that the predicate function is transitive, which guarantees the existence of a total ordering.

  Better(A, B) && Better(B, C) means that Better(A, C)

Otherwise there may be only a set of partial orderings.
(End of pedantry ;-) )
Matt T Heffron 13-Jun-16 16:55pm View
There is enough work in solving this question to cover getting several PhDs!

You should do some basic background work in understanding the various parts of the field of AI (Natural Language Processing, Knowledge Representation, Fuzzy Logic, Inferencing, Machine Learning, Computer Vision, Automated Translation, etc.) and then you can pick an area in which to focus your efforts.
Matt T Heffron 13-Jun-16 14:15pm View
I've just been reading about FileSystemWatcher, and it appears that the Created event happens when the file is first opened for writing. Don't you have to wait for the size or last write time to stop changing (Changed event) for some time (application specific) to know when the file is finished being written and Closed?
Matt T Heffron 13-Jun-16 14:08pm View
"Virtual +5!"
Matt T Heffron 10-Jun-16 16:24pm View
Besides the fact that what you gave won't even compile, and uses an incredibly convoluted way to get the Date and Time from a DateTime value, this question was asked and answered six years ago!
What you provided does not add any significant value to the solutions already provided.
Matt T Heffron 9-Jun-16 20:26pm View
Agreed that assumptions can be way off!
I attempted to cover myself for that case with the first line disclaimer! ;-)
Matt T Heffron 9-Jun-16 19:33pm View
Matt T Heffron 9-Jun-16 19:17pm View
Yes ... there is no foreach syntax for the construct OP presented, but solving for the apparent intent is actually pretty nice with Linq.
See my Solution 2.
Matt T Heffron 9-Jun-16 19:14pm View
You're welcome!
(Out of curiosity: Which way of using .Zip() did you choose?)
Matt T Heffron 9-Jun-16 19:12pm View
Rick: You said: "If you are not an experienced programmer I would avoid WPF, in my opinion this is much harder to start with than Winforms"

I disagree. A lot of the difficulty many experienced developers have with WPF is unlearning the Winforms way of doing things.
Starting with WPF's declarative mind-set may be easier to pick up for an inexperienced dev. vs. an experienced one.
Matt T Heffron 9-Jun-16 18:33pm View
Thank you.
Matt T Heffron 9-Jun-16 16:10pm View
Matt T Heffron 8-Jun-16 14:20pm View
This question doesn't quite make sense.
To compare requires some kind of comparison operation.
If you can't use any of the "eq"-type operations, how do you expect to compare the elements of the lists?
For numbers you could subtract and use (zerop ...), but that's an obvious HACK!
Is your question about how to walk the lists "in parallel"? How to structure the overall comparison? Looping vs. recursion vs. some of both?
Use the "Improve question" to clarify what you are really trying to solve.
(Since comparison of lists is already available in lisp, this looks like a homework assignment type of question.)
Matt T Heffron 7-Jun-16 12:21pm View
Matt T Heffron 7-Jun-16 0:23am View
It's setting that cell (1,19) of worksheet 1 to be the string "=COUNT(c[-18])"
That's an Excel function call.
Not VB
Matt T Heffron 6-Jun-16 20:21pm View
You showed what you is that different from what you actually got?
(Use the "Improve question" above to add the information, and any other information that may be useful, like: does it work for some inputs but not others?)
Matt T Heffron 2-Jun-16 13:40pm View
In addition to giving more information as Richard suggested,
Are the SrCreated and SrSolved totally independent?
Are they compute-bound or IO-bound?
Are there any resources that they must share in a manner that allows for updates?
Do they each need their own results of Global() and ChildAccess()? or do they share the results (which is kind of implied by part of your question about start-up)?
Are they large enough (memory-wise) that switching between the threads will affect caching?
Just putting things in multiple threads is not necessarily going to make it faster?
Matt T Heffron 2-Jun-16 13:16pm View
I gave you the big hint.
@ppolymorphe gave you a link.
Some things you really do need to work out for yourself.
Learning is more than just knowing the answers to questions, it's about understanding concepts.
It's the difference between "knowing what to think" and "knowing how to think". (That's a big difference!)
Matt T Heffron 2-Jun-16 12:38pm View
Think about how a genetic algorithm is implemented.
It depends on random processes (a pseudo-random number generator) at various points in the algorithm.
What does use of a random process imply to you about repeatability?
Matt T Heffron 2-Jun-16 12:29pm View
Virtual +5.
OP could create a Data Access Layer, starting with Dictionary as Richard suggested, while working out the non-storage part of the application (e.g., parsing, indexing, lookup, ...).
When "ready", switch to database without needing to change (much of) the rest of the application.
Matt T Heffron 1-Jun-16 13:36pm View
Did you get this working?
Was any of the advice (Solutions) helpful?
Matt T Heffron 31-May-16 20:54pm View
I agree.
(I got an email notification that this was a reply to my comment, but it displays here as the more likely reply to Jammes_Ca. Hmmm.)
Matt T Heffron 31-May-16 17:22pm View
OK, then for just an array, use the second block of code above.
(The block starting with int [] marksNew .)
That will create a new array which is a copy with the specified element omitted.
At the end of that block, the marks is replaced with marksNew.
As I noted, to do it in place, you cannot change the size of the array and must fill the tail of the array with some value to indicate invalid. Or you must keep a usable length value that you reference everywhere you use marks so you know how much of it is valid.
Matt T Heffron 31-May-16 14:41pm View
OK, then the code in the first half of my solution are ways to do that covering both modifying the array in place, and making a new array with the element removed.
The only reason you should need to modify an array in place would be if there is some other part of the code that already has a reference to that array and there's no way to have that reference updated.
If this is the only reference to the array and making a replacement array is OK then the second, third and fourth code blocks above are your options.
If you can switch to declaring marks as a List<int> instead of a int[] then just using marks.RemoveAt(...) is the ultimately simple solution!!
Matt T Heffron 31-May-16 13:51pm View
ArrayList is almost absolete as it isn't type-safe.
Generic List<T> is a much better choice.
(ArrayList is really only a better choice if the contents are mixed types.)
Matt T Heffron 31-May-16 12:45pm View
This question was asked and answered over 3 years ago!
Your Solution (which you posted twice!) appears to be a totally different question, unrelated to the original question.
You should delete these Solutions and, instead, post your question using the "Ask a Question" button on the Questions page.
Also, be sure to specify clearly the difficulty you are having with your code. (In English, please! Use an online translator if necessary.)
Matt T Heffron 27-May-16 17:23pm View
Virtual +5
Matt T Heffron 27-May-16 17:16pm View
Unlike with C/C++, the C# language specification defines (see sections 4.1.5 and 18.5.8) the exact sizes of int and long (4 and 8 bytes, resp.), as well as for most other "fundamental" numerical types and char and bool.
Matt T Heffron 27-May-16 17:06pm View
You posted this as a Solution.
You also need to tell us:
Does this work? Or is it just your latest attempt?
Matt T Heffron 26-May-16 13:50pm View
This question is over three years old and your post adds nothing new (in fact it is exactly the same advice as given back in 2012!!!)
Matt T Heffron 26-May-16 13:10pm View
Instead of communicating via the comments on a 3 1/2 year old question, a better idea might be for you to write a Code Project Article about this LAS application and your experiences and lessons learned. (It appears that you probably would want to collaborate with "Zaf".)
You could attach the source code to the article.
Just a suggestion!
Matt T Heffron 26-May-16 12:28pm View
This was entered as a reply to my comment, not to @CHill60 who posted the solution.
Be sure to respond to the correct message; that way the appropriate person will be notified of your response.
Use the "Have a Question or Comment?" button to respond directly to the Solution.
Use the "Reply" button to respond to a specific Comment.
Matt T Heffron 25-May-16 17:30pm View
So it becomes:
foreach (Dictionary<string, int> inner in ID.Values)
// here inner is the same as your code, but doesn't require dealing with
// KeyValuePair...
// etc...

In fact, your code requires creating all of the KeyValuePair instances, while iterating over the ID.Values doesn't need to.
Matt T Heffron 25-May-16 16:39pm View
This looks an awful lot like the solution I posted on the previous version of this question 2 days ago... ;-)
(Admittedly, I gave the solution in C#, but the principles are all the same.)
Matt T Heffron 25-May-16 16:35pm View
This is essentially a duplicate of the question you asked 2 days ago.
The main difference here is that you are assuming a specific partial implementation (tries and split files).
I gave a very extensive solution (click here) that traded pre-processing time to gain fast lookup time.
(Admittedly, I gave the solution in C#, but the principles are all the same.)
Matt T Heffron 25-May-16 15:53pm View
Matt T Heffron 25-May-16 15:41pm View
Matt T Heffron 25-May-16 15:28pm View
If just getting the Value of the pair, then:
foreach (var inner in ID.Values)
// etc...

is much simpler!
Matt T Heffron 25-May-16 15:18pm View
We don't do your homework for you.
We're all volunteers here, with our own "real jobs".
If when you try to do it yourself and run into a specific difficulty, then come back and ask a specific question.
Then you will be likely to get a lot of assistance.
(But no one is going to do it for you.)
Matt T Heffron 24-May-16 16:54pm View
This is making a huge assumption that the problem is overwhelming the database.
It could be a poor implementation of multi-threading.
Like Richard MacCutchan stated, there really isn't enough information to know where the bottleneck is.
Matt T Heffron 24-May-16 16:50pm View
Don't post a comment on someone else's solution as a new Solution.
Use the "Have a Question or Comment?" button below the Solution.
Or in the case of replying to a comment, use the "Reply" button next to the comment.
Matt T Heffron 24-May-16 16:47pm View
Do you have any additional information?
Was the conversion by your friend in a .NET application? Linux? Unix? other?
Are you sure that it represents exactly May 2, 2016 at 00:00:00 (midnight)?
Which timezone is it supposed to be? Are you sure your friend didn't use a different timezone?
Matt T Heffron 23-May-16 12:28pm View
There's an ambiguity in your question:
At first you state: "we have 20 gb of text files" using plural files
Then you state: "the huge files like 20 gb"
So, the question is: Are the individual files 20 gb, or only the total size of all of the files?
This can make a big difference in how you could approach the problem.
Matt T Heffron 20-May-16 13:37pm View
Well, you are clearing and reloading the ContextMenuStrip1.Items inside the While loop, so of course it is changing multiple times!
Matt T Heffron 20-May-16 13:13pm View
OK, I see you updated the "What I have tried" code...
(I fixed the formatting...)
You haven't said what's wrong (or right) with that new code!
Matt T Heffron 19-May-16 21:04pm View
Also, likewise, the
<param name="ProductType" value="" require="" read-only=""><![CDATA[False</param>
are missing the
]]> before the </param>
Matt T Heffron 19-May-16 19:51pm View
Matt T Heffron 19-May-16 18:44pm View
You need to go back and really learn how, and when, to pass arrays to functions.
You never modify the contents of the card_array so special_card will always just return NumOfCards (which is NOT the same as NUMOFCARDS, C is case-sensitive!)
Matt T Heffron 19-May-16 18:35pm View
I have a soft spot for that function...
It was first presented to me in a Caltech undergraduate Computer Science class. The professor showed a stack tower of printout showing the stack depth over the computation!
Later I was playing with it a bit, and a couple of days later it appeared in a question on the Comp. Sci. Graduate School applicant standardized test!
Matt T Heffron 19-May-16 16:30pm View
Instead of replacing all of the code in the "What I have tried" section, just replace the changed code, being careful to use the character elements for the <, > and & (that's &lt; &gt; and &amp; respectively!)
That way the code will still format correctly.)
Matt T Heffron 19-May-16 16:19pm View
With lots of commands, the if or switch solutions take (on average) time proportional to the number of commands to "consider". O(n)
The solution with Dictionary is constant. O(1)
Matt T Heffron 19-May-16 16:09pm View
So what's the problem with the way it is printing the cards?
It looks correct from your example output.
But not from the code! See solution below.

You probably need to add code to make sure that there are only 4 of each value of card played from each shuffle of a deck. (Or 4*n for n decks played together.)
Also, you need the "house" to "hit" until the cards total 17 or more.
Matt T Heffron 19-May-16 15:24pm View
You've lost me.
I don't use LINUX and I'm not familiar with these specific compiler messages.
However, I think:
the 'sleep" error means you need #include <unistd.h>

You stated that you didn't need to get any data back, so you should be able to delete any use of recvfrom. Or change the declaration of slen from int to be socklen_t.

The last error you show looks like there is a missing ; typo in the code. (On the sleep(1) line?)

The others are warnings of doing things that are unsafe.
Switch the gets(message) to fgets(...).
gets is inherently unsafe as there's nothing to prevent more than input than will fit in the buffer passed to it.
Matt T Heffron 19-May-16 14:19pm View
What kind of errors did you get from what you tried?
Run-time? Compile-time?

Since we don't know WHICH tutorials you tried, we can't even evaluate if they're good or bad examples.

I just found this:
Their Client example is pretty straightforward.
To send without listening, just skip the recvfrom part.
(I'm not a LINUX developer.)
Matt T Heffron 19-May-16 14:07pm View
What does this have to do with Lisp? (You tagged "Lisp"; I added the VB.NET tag.)
"What I have tried" is where you show the code of what you're already doing (just the part essential to the specific question).
Matt T Heffron 19-May-16 13:59pm View
So, if there are multiple records that match the words, how do you want to display them? I don't see anything in your code that looks like a grid type display.
Matt T Heffron 19-May-16 13:56pm View
See my Solution 4 for thoughts on many, many commands efficiently.
Matt T Heffron 19-May-16 2:36am View
Get rid of the .FirstOrDefault()
That means that Obj_SalaryAndTaxInfo will not be a single instance of that type, it will be an IEnumerable<theType>
So you'll need to foreach over Obj_SalaryAndTaxInfo and do the appropriate steps with each of the instances in the enumerable.
Only you can determine what the "appropriate steps" are. You have your requirements, we don't.
Matt T Heffron 19-May-16 2:24am View
Didn't you mean .ToUpper()?
Or all the strings you compare to should be all lowercase...
Matt T Heffron 18-May-16 15:49pm View
Thank you
Matt T Heffron 18-May-16 13:04pm View
I think this might be an issue with the wrong multiplication operator in Matlab. See my Solution.
Matt T Heffron 17-May-16 17:50pm View
Matt T Heffron 17-May-16 17:43pm View
Following up on my comment below.
ML on raw images is probably computationally intractable.
(At least, a very large computational requirement.)
Determining a small feature set that can be pre-computed easily is probably the only practical strategy.
My first thought would be first to trim and scale all the images to the same size (at least approximately align the baseline and horizontally center the trimmed image in the final size "canvas"), then get some simple features like horizontal and vertical symmetry, overall intensity.
Then, you should split the feature data into training and testing data sets.
Do this split randomly! Do not peek when choosing which data are for training vs. testing!
Matt T Heffron 17-May-16 17:04pm View
When I took the course in Nov. 2012, I used libsvm from Octave and only used what was necessary for the SVM homework. I don't have recollection of the details of libsvm capabilities and usage model. Neither have I used EMGU CV, libsvm-csharp, etc.
Here are a couple of additional links to SVM/C# related articles (using a different free ML library, Accord.NET):
Sorry I can't offer more assistance.
Matt T Heffron 17-May-16 16:50pm View
Matt T Heffron 16-May-16 17:25pm View
Matt T Heffron 10-May-16 18:47pm View
I added it to the Solution.
This pretty much exhausts my ASP.NET knowledge, so I'm not likely to be any more help. :-( Sorry
Matt T Heffron 10-May-16 18:27pm View
OK, I'm confused.
I just tried this (in C#) in a new ASP.NET Web Application project.
I added the C# equivalent of your original code to the provided About.aspx page, in the Page_Load method.
It works fine and displays a 2 column grid with 1 row.
The column headings are the two string used.
I don't know what the problem is for you.
Use the debugger to see if you can get more information about the what's happening when you get the error.
Matt T Heffron 10-May-16 17:08pm View
dt.Columns.Add("[apple 1]")
mr("[apple 1]") = "ipod"
Matt T Heffron 4-May-16 14:57pm View
Use "Improve question" above, clarify what you are trying to do, and show us the relevant code for what you've tried.
We don't even have the context for what you are doing! There's no way we can help without more information!
Matt T Heffron 2-May-16 16:23pm View
If the page "stops" after a few seconds, then there is some problem in the code. It just isn't in the part that executes when loading the page. Or it is that loading the page leaves some debris behind on the server (unreleased resource, etc.) that causes the error a few seconds later.
Maybe it is using some feature improperly.
Matt T Heffron 2-May-16 1:59am View
So did you set the breakpoint on the line I suggested?
Single step one line and then look at the contents of the elems collection.
Does it contain the elements you expect?
If not, then you'll need to do some research to see why.

The behavior you describe sounds like classstr is the empty string, which is what happens if the elem doesn't have an attribute named "class".

We can't really debug your code from here, you're going to have to do that part yourself.
Matt T Heffron 1-May-16 17:44pm View
So, after fixing this, you need to use the Visual Studio debugger and single step through the code and see where it stops doing what you expect!
Set a breakpoint on the elems = WebBrowser1... line, execute the code, and step line by line and examine the contents of the variables.
If you don't know how to use the debugger, then it's time to learn! This is a skill that is essential to your ability to write code in the future.
There are many resources on line to help with this. Google is your friend!
Matt T Heffron 1-May-16 17:44pm View
So, after fixing this, you need to use the Visual Studio debugger and single step through the code and see where it stops doing what you expect!
Set a breakpoint on the elems = WebBrowser1... line, execute the code, and step line by line and examine the contents of the variables.
If you don't know how to use the debugger, then it's time to learn! This is a skill that is essential to your ability to write code in the future.
There are many resources on line to help with this. Google is your friend!
Matt T Heffron 1-May-16 17:38pm View
What is different about the line of code that you posted and what I posted?
You had: (classstr Is Nothing)
I had: (classstr IsNot Nothing)
You were only going to enter the Then of the If in the case of classstr being Nothing
In fact, if classstr were ever Nothing then the classstr.Length would have caused a NullReferenceException to be thrown.
So, what you have will never execute the body of the If statement!
Matt T Heffron 1-May-16 2:07am View
using System.Collections;
to the file.
If you had right clicked on the IEnumerable with the wiggly underline, one of the options would be "Resolve >" and in the slide out menu is that "using" as above. Click that and Visual Studio would have added it to the file for you.
Matt T Heffron 29-Apr-16 21:44pm View
for both
Matt T Heffron 29-Apr-16 20:07pm View
It is just one of the constraints of WPF that bindings must be to a property, not a field (or const).
For WPF controls to notice when the property to which they are bound has changed value, the DataContext (the Window itself in this case) must implement the INotifyPropertyChanged interface, and then raise the PropertyChanged event whenever a property value changes.
See my updated Solution, above.
Matt T Heffron 29-Apr-16 14:17pm View
Matt T Heffron 29-Apr-16 14:05pm View
OK, I agree that doing it with the Canvas.SetLeft() method is the correct way to do it.
(I was just asking about equivalency. Would both ways accomplish the same thing? Even if one way was not recommended.)
Matt T Heffron 29-Apr-16 13:38pm View
I see I had a "think-o" ;-)
I should have used Canvas.LeftProperty, etc.
Would that be equivalent to your code above?
Matt T Heffron 29-Apr-16 13:26pm View
(I just fixed a pretty obvious typo...)

Also, isn't the
redundant since the conn is created in a using statement and would be closed when disposed at the end of the block?
Matt T Heffron 29-Apr-16 13:19pm View
Would the
Canvas.SetLeft(someElement, 0);
be equivalent to my
th.SetValue(Canvas.Left, 0);
(where my th corresponds to your someElement)?

(And shouldn't your MyCanvas. be Canvas. as it is referencing the static method?)
Matt T Heffron 27-Apr-16 20:57pm View
Paulo, Did you solve this?
I posted a Solution a couple of months ago and I'm wondering if it helped...
Matt T Heffron 27-Apr-16 17:02pm View
At the top you say "union" of the conditions, and at the bottom you say "intersection". Which is it?
Matt T Heffron 27-Apr-16 16:57pm View
This is quite unclear!
Your example of the output doesn't explain exactly what you want to calculate.
A: 2-3|3-2
doesn't have a "standard" meaning, and I can't deduce one from the whole example.
A has both 2 and 3 in equal number
B has all 4
C has four 7s and two 6s
D has one 4 and the rest 5s
What do you want to do with that?

Once you get the definition clarified, reading from a CSV file is going to be another task. You'll be tempted to write that yourself.
There are several free packages/libraries that make it easier.
A Fast CSV Reader seems to be highly considered.
There are others.

Use Improve question above to clarify your problem.
Matt T Heffron 26-Apr-16 13:38pm View
You had logical OR where you meant logical AND.
(Logical OR would always test as true.)
Matt T Heffron 25-Apr-16 14:15pm View
Andreas, How did you finally resolve this requirement? (Did you?)
A coworker on a different project has what appears to be the same requirement.
"Verify the integrity of the text file contents"
Their current thoughts are CRC32 of MD5 Hash.
This is not going to be secure.
Matt T Heffron 22-Apr-16 3:11am View
Great minds think alike!
You just typed faster... ;-)
Matt T Heffron 22-Apr-16 2:21am View
I didn't actually intend that you modify your comment. Only that my "instructions" were visible to the OP; and that I knew that you already knew this!
Matt T Heffron 21-Apr-16 20:32pm View
(For the sake of the OP:)
Don't put the code in a "Reply" here!
Use the "Improve question" above, and use the correct markup tags!
Matt T Heffron 19-Apr-16 18:48pm View
Matt T Heffron 15-Apr-16 16:33pm View
+5 for the answer (and for patience!)
Matt T Heffron 14-Apr-16 12:53pm View
They're still not quite equivalent.
The first two will set result to a single Reservation instance or null.
The third will set result to an IQueryable<Reservation>, possibly empty.
Matt T Heffron 13-Apr-16 20:07pm View
What is the code that you already have?
(You do already have some code to do this, right?! Even if it doesn't work...)
Just show us the part where you tried to find the difference.
The rest should just be "standard" to do a web page.
Matt T Heffron 13-Apr-16 19:53pm View
For consistency between the two ways, the SingleOrDefault probably should be Where.
SingleOrDefault will return either the only matching object, or null if zero or more than one matches.
Matt T Heffron 13-Apr-16 13:20pm View
I did notice that two other Solutions were "recent", so I didn't look at the original date.
Matt T Heffron 11-Apr-16 20:52pm View
So it appears that the exact issue I mentioned above is happening. The source collection is being modified during the copy operation that's inside of the GetEnumerator() of the foreach.
See my updated Solution.
Matt T Heffron 8-Apr-16 21:59pm View
In my defense, I said "this looks like valid ASP.NET..."
Matt T Heffron 8-Apr-16 19:22pm View
Sergey, this looks like valid ASP.NET syntax (for the part of interest).
(And I fixed the markup...)
(No, I'm not any kind of ASP.NET guru. I just had a suspicion! ;-) )
Matt T Heffron 8-Apr-16 18:41pm View
And, I had omitted that the Invoke() is also to be removed when switching to the foreach.
Matt T Heffron 8-Apr-16 18:38pm View
On which line is it failing?
Is it still failing with an index out of range exception, or something else?

The HtmlElementCollection.GetEnumerator() copies from the source collection to a new array and iterates over that, so unless the source collection is changing in the middle of the GetEnumerator executing, I don't see how the foreach can fail.
Matt T Heffron 7-Apr-16 19:17pm View
Just make a newTotalDays = totalDays + n;
Then convert newTotalDays back to y/m/d.
Matt T Heffron 7-Apr-16 19:12pm View
Since you claimed in the other posting that you would have needed to submit the assignment by now, I'd suggest that you restore the Question code there so that all of the context of that discussion there makes sense whenever anyone may find it in the future.
(Right below the code block in the question is a little "v4". Click that and you should be able to "Rollback" to the Revision "4 - publicly available")
Matt T Heffron 7-Apr-16 19:03pm View
The Gregorian calendar was first established in the late 1500's so any attempt at a date calculation before that would not be correct.
But, if you assumed that the Gregorian calendar has always been in use, all of the calculations are the same except you should probably choose some large negative number as the reference year. (Not too negative, you have only about 5.8 million years with a 32-bit int to store the totalDays!)
You probably have to special-case year zero. There was no such a year! But since this is now a new calendar system you can define it such that year zero is OK. (Apparently, it was a leap year!)
Matt T Heffron 7-Apr-16 18:57pm View
You cannot delete a question once it has a Solution.
Matt T Heffron 7-Apr-16 18:54pm View
My suggestion in the other posting is pretty much what nv3 suggested here.
It isn't difficult!
Try doing it on paper first.
With my suggestion of 1/1/1600 as the "reference year" try calculating the number of days until March 6, 2000 (inclusive!).
First 2000-1600 gives a yearsSpan of 400
400 / 4 potential leap years is 100 * 1461 days = 146100
(1461 is 366 + 3*365)
but there are 4 centuries so subtract 4
but there is 1 400-year block so add back 1
so far totalDays is 146097
We're in month 3 so add 31+28 for the number of days before March.
totalDays is now 146156
add 6 for the specified day of the month
totalDays is 146162
Check for a leap year:
2000 is a leap year so add 1
the total number of days from 1/1/1600 up to including 6/3/2000 is 146163
So now you can add the n.
Then just convert this number back to d,m,y.
First figure out how many years, then which month, then the day of the month.
Matt T Heffron 7-Apr-16 18:39pm View
This looks an awful lot like the advice I gave a couple of hours ago on the earlier posting of this same question (under a different membership!) at
Matt T Heffron 7-Apr-16 18:35pm View
BTW. The leap year rule is every year that is a multiple of 400 is a leap year, not multiple of 1000.
Matt T Heffron 7-Apr-16 18:31pm View
It looks like you created a new membership to re-ask this question!
This is essentially a repost of "C program that gives me the date after n days" ( where I gave you significant guidance.
(It appears that you deleted most of the code that was in the "What have I tried" section. Don't do that! It destroys the context of the discussion on that question.)
Matt T Heffron 7-Apr-16 16:15pm View
OK, for staters, I'm assuming this is some form of coursework (since there's no other obvious reason to do this) so I'm not going to just give you the solution, but I'll try to guide you through it. (It would be nearly trivial in C#!)

The code you have "parses" the input date into day, month, and year.
(It's not pretty but it looks like it works.)
You would need to choose a reference year, say 1600, and then invalidate the input if the user gives an earlier date than 1/1/1600.
Now you need a variable to hold the calculated total days since the reference year.
(A 32 bit int will allow for up to 5.8 million years!)
First subtract 1600 from the input year value into years.
Calculate the number of "potential" leap years in that value: years / 4
Put 366 1461 (= 366 + 3*365) times that into the total days variable.
Then figure out how many century years there were: years / 100
Subtract that number from the total days (those weren't leap years).
Then add back in for the years divisible by 400: years / 400
At this point you have the number of days from 1/1/1600 to just before the user input year.
Now you need to add in the appropriate number of days to the beginning of the user input month.
If the month is after February, then account for year being a leap year.
Then add in the input day value.
This is now the total number of days from 1/1/1600 to the input date (inclusive)!!

Now you can just add the days offset (n) to the total.
Then you can "unwind" the calculation above to get the new day, month, year.
Matt T Heffron 7-Apr-16 15:40pm View
Give me a bit of time to compose a response... It'll take a short while!
Matt T Heffron 7-Apr-16 15:29pm View
Matt T Heffron 7-Apr-16 15:28pm View
The way I'd do this would be to convert the input date to an integer representing the number of days since the beginning of some reference year.
(You could calculate days since the beginning of year 1, there was no year 0, but that assumes the current calendar system back before it was in use!)
Then add the number of days offset (n) and convert back to day, month, year. The hardest part of converting back may be determining how many leap years to account for.
Matt T Heffron 7-Apr-16 15:17pm View
In the future, don't put updated code in a "Reply".
It's pretty unreadable here.
Use the "Improve question" on the original question to make changes.
I've done it for you this time.
Matt T Heffron 7-Apr-16 14:16pm View
You've tagged WPF but say it is "Windows Forms" ... Which is it? (Fix the tags if necessary.)
Matt T Heffron 7-Apr-16 13:04pm View
So what value do you get back in that case where the user didn't select the time?
If you convert the input (string I presume) to a C# DateTime value (using DateTime.TryParse()), then if there is no time of day in the string, then the time in the value will be defaulted to 00:00:00, which seems to be what you want.
Matt T Heffron 6-Apr-16 15:36pm View
Jochen said the code looks correct (and I think so, also).
You said: "but the code still not works!"
What is happening, or not happening?
Is it crashing? Infinite loop? Nonsense output?
We can't help if we don't know what is going on.
Matt T Heffron 6-Apr-16 2:00am View
I'm working on a thesis project
I hope this is a "thesis" in some other field that just needs you to do a bit of coding, not a Computer Science (degree?) "thesis"...
I'm sorry to say that the code you've shown is abysmally bad!
Back when I was a Teaching Assistant for a programming class, code like this would not have been acceptable!
Matt T Heffron 6-Apr-16 1:44am View
I didn't say anything about "translation"...
I did refer to "transactions" and "transcribe" ;-)

BTW. What Android "dictation keyboard" are you using/recommend?
Matt T Heffron 6-Apr-16 1:41am View
Project Oxford is the "old name" for Microsoft Cognitive Services.
The "Get started with Speech Recognition and/or intent in C# for .Net Windows" info is at:
This requires registration. Follow the instructions on this link.
(I have not tried this! But some day...)

It's probably not going to be "straightforward" for "a newbie in C#". Sorry.
Matt T Heffron 5-Apr-16 16:58pm View
OK, I have no experience with dictation keyboard apps.
(Even so, I'd guess/expect that it is pretty limited compared to something that could transcribe recorded phone calls.)
Matt T Heffron 5-Apr-16 16:16pm View
Yes, this would be Software as a Service (SaaS).
So is Siri dictation.
Are you sure that the Android dictation input isn't SaaS?
On my Android tablet, I can't even use voice input for asking a question without a network connection back to Google. Generalized dictation would probably be even harder.
The different speaker models (dialects, accents, ...), vocabulary, environmental acoustics adaptation (noisy, quiet, echoey...) make this general case too hard for (most) stand-alone systems.
I can easily believe that the Speech-SDK has been "frozen" at the current capabilities.
For the original question, SaaS with a high quality system might be the perfect solution! (Currently 5000 transactions per month are FREE! $4/1000 transactions (<= 15 seconds) above that.)
If it were my project I'd certainly look into it!
Matt T Heffron 5-Apr-16 15:39pm View
Are you attempting the Strassen algorithm?
Matt T Heffron 5-Apr-16 15:21pm View
The recent announcements at the Microsoft Build 2016 include (apparently) much higher quality Speech Recognition capability using APIs against services on Azure. (I can guess where their speech recognition development effort went.)
Microsoft Cognitive Services: Speech API
Matt T Heffron 5-Apr-16 14:48pm View
Richard's solution is right. You just need to declare, allocate, use and free arrays (A??, B??, X??, C??) locally to your MMult function.
However, the algorithm you show will work correctly only for square matrices with rank equal to a power of 2!
Is it really more efficient than the triple-nested loop that handles the general case of an NxK mult KxM giving a NxM?
Matt T Heffron 31-Mar-16 12:53pm View
This is a 6 year old question! Asking your NEW question here is pretty pointless.
Almost no one will bother to look here.
Delete this and post this as a NEW question: use the red "Ask a Question" button above!
Matt T Heffron 30-Mar-16 17:52pm View
One problem with always filling all 9 positions of the board (even if you account for 5 Xs and 4 Os (or vice versa)) is that some of these board states will not be definite who won. (That's because the end of game state was not a full board.)
For example:
You can't know who won.
You can't know even if you know who had the first move.

You must determine the win/loss/tie based on the board state after each move!
Matt T Heffron 30-Mar-16 17:34pm View
From the Standard Numeric Format Strings link you provided, "D2" will pad 0-9 with a leading 0, >= 10 will not pad.
If the OP knows that their values are all <= 99, then "D2" is a perfectly valid way to accomplish output with a fixed width of 2 chars.
Matt T Heffron 30-Mar-16 17:26pm View
Good points. (+5)
I interpreted the question as if OP was generating 9 random values, each 0 or 1 representing an X or O in a "cell". (Perhaps to generate input for a learning algorithm... albeit, not very useful input!) But the problem was that the relative counts of X and O was not balanced (5 to 4): the only valid states for "played" games.
(This is clearly wrong as it accounts for "full" boards only, and many of these board states would be impossible since the game would have ended before filling the board.)
Matt T Heffron 30-Mar-16 15:11pm View
Instead of saying you "tried a variety of things", show us the code for them (at least some of them). Then we can better see how to point you in the right direction.

Since this looks like homework, you are not likely to get working code, but maybe some hints.
Matt T Heffron 29-Mar-16 16:17pm View
Matt T Heffron 29-Mar-16 16:16pm View
So... is there some clarification you're going to add?
Is your question solved?
Matt T Heffron 29-Mar-16 15:09pm View
You're asking everyone for their "Project source"
The impression you are presenting is that you are unwilling or incapable of doing your own work. This is probably not what you want to do.
Matt T Heffron 29-Mar-16 13:56pm View
You should DELETE this "solution" and repost it as a new Question.
It is very unlikely that anyone who can help you would see this here.
Matt T Heffron 29-Mar-16 12:23pm View
This is essentially a duplicate of your question of a few minutes earlier.
You should just use "Improve question" to change the other question.

There is no appreciable difference between the two.

"What I have tried:" should be showing what you have done to address the specific question, not just telling what parts you already have working.
In this case, here (in the other question) you could put a description of HOW you think it should be architected/designed.
Matt T Heffron 28-Mar-16 20:39pm View
You should post your question as an independent question (and then delete this Solution from here!)
It is very unlikely that someone who can answer this would see it here!
Matt T Heffron 28-Mar-16 20:37pm View
This was answered over 5 years ago!
If you have a new, "better", algorithm then you should write an article about it.
(Is it based on a "known, published" algorithm?)
Posting it as a Solution to an old, already solved question is not a good way to build credibility here at Code Project.
Matt T Heffron 28-Mar-16 14:00pm View
I'd have to Google it and you can do that as well and can decide which result makes the most sense to you.
I suggest searching:
convert float to string algorithm
Matt T Heffron 24-Mar-16 18:29pm View
It looks like you can just use count instead of unique.
Matt T Heffron 24-Mar-16 13:16pm View
OP's problem is more fundamental.
The concept isn't understood.
Matt T Heffron 24-Mar-16 13:15pm View
Of course!
See my Solution below.
Matt T Heffron 23-Mar-16 19:04pm View
Matt T Heffron 23-Mar-16 19:04pm View
Matt T Heffron 22-Mar-16 12:32pm View
So it sounds like the problem is in converting your Java implementation to C#.
In the "What I have tried:" section, show us the relevant parts of both implementations.

This way we can see how to help. Right now there's nothing we can do.
Matt T Heffron 18-Mar-16 20:01pm View
Matt T Heffron 18-Mar-16 18:29pm View
Easier said than done!
Maybe it'll work if it was coded against a comparatively recent C++ standard.
We have a LARGE VC6 C++ application and trying several years ago to compile it as C++/CLI gave tens of thousands of errors!

Edit: I wasn't trying to imply that this was a bad suggestion!
This is an excellent suggestion.
I was just trying to "set expectations" that it wouldn't be automagic!
Matt T Heffron 18-Mar-16 14:38pm View
This moves the handling of the nulls out of the GET_Y_SERIES method and makes it the responsibility of all of the callers.
(You don't need to allocate the "new double[21]" since you are about to replace it on the next line.)
Matt T Heffron 17-Mar-16 17:41pm View
This question is 2 years old, but since you used out parameters (for the most part correctly) and that was one of my first thoughts, I'll give you a 4.
Matt T Heffron 17-Mar-16 13:52pm View
Matt T Heffron 17-Mar-16 12:43pm View
You're welcome!
Please rate this solution as you see fit, and formally accept it if it seems appropriate. See QA FAQ
Matt T Heffron 16-Mar-16 17:01pm View
The first question this brings to mind is:
What are you expecting to do with these strings?
What is the actual problem you are trying to solve?
Matt T Heffron 15-Mar-16 20:13pm View
The computational complexity of this is O(n * m) !!
For each entry in lstreader this is creating a new array of the ids from dt.
All of those arrays are identical!
And then it is doing a linear scan of that array.
See Solution 2.
Matt T Heffron 15-Mar-16 12:46pm View
Don't repost!!!