Click here to Skip to main content
14,972,394 members

Comments by Jon McKee (Top 152 by date)

Jon McKee 24-Jun-21 4:59am View
   
Looks like an ASP.NET XML file.
Jon McKee 1-May-21 17:20pm View
   
revokeObjectURL should be on the image's onload event. It destroys the object URL so should only be called once the image is loaded.
Jon McKee 18-Apr-21 7:40am View
   
It also has multiple null pointer exceptions once you add a main. I'm reminded of why you never nest class definitions in Java as well...

gamelevel1.Pictureslevel1.PicturesLevel1 game = new gamelevel1().new Pictureslevel1().new PicturesLevel1();
Jon McKee 25-Mar-21 15:30pm View
   
If the number is the volatile data, maybe index on "Alex" instead if possible? Other than that, Gerry's response is really all you can do. Adding/deleting pairs isn't computationally expensive so it's not really an issue in my opinion.
Jon McKee 22-Sep-20 4:16am View
   
*IEEE cries in a corner*
Jon McKee 22-Sep-20 4:07am View
   
I've somehow managed to never use PHP, lol. On a side note, wouldn't it be wonderful if everyone followed the regex standard? It's so irritating learning a slightly different syntax for every language.
Jon McKee 22-Sep-20 3:34am View
   
+5! Nice regex. I wasn't aware of the ?P<> syntax since I mostly do C# which uses just ?<>. TIL.
Jon McKee 26-Aug-20 1:56am View
   
Same. It took me a minute to figure out why my IDE was saying Food wasn't a type, lol.
Jon McKee 25-Aug-20 23:56pm View
   
+1: I like that you point out a better strategy for initializing things.

This is C though, so you need struct Food lunches[LUNCH_QTY] and struct Food * pfood. Also in the scanf, it should be &pfood->weight and &pfood->calories. With those changes this compiles and runs fine :)
Jon McKee 25-Aug-20 23:37pm View
   
That's a lot of changed code.
- Think about that for loop carefully, specifically <=. You're creating 3 lunches (lunches[LUNCH_QTY]), but arrays are zero-indexed, so what total lunch count is lunches[3]?


Nvm, you can use just name. scanf has no issues with just using name as Rick's example works. It's been a minute since I've used good ole C. Your original example with my changes runs fine, and Rick's example below with my notes runs fine, so you've got two examples to work from :)
Jon McKee 5-Aug-20 0:24am View
   
Because it's definitely a homework assignment in C++ which he's possibly avoiding learning because he knows Java.
Jon McKee 15-Jul-20 0:46am View
   
I hope you figured it out. If the instructions actually require you to read doubles as if they were floats like this I would ask the teacher about it.

This code will show you what I'm talking about if you enter the same value twice. Floats and doubles have different memory formats.
int main()
{
	double input1 = 0;
	
	//Different precision reads
	scanf("%g", &input1);
	printf("G (float) read: %g\n", input1);
	scanf("%lg", &input1);
	printf("LG (double) read: %g\n", input1);

	//Examining the hex of double vs float
	printf("\nRaw double: %-g\t\t0x", input1);
	for (int i = 0; i < sizeof(double); i++)
		printf("%02X", *(((unsigned char *)&input1) + i));
	printf("\n");
	float input2 = (float)input1;
	printf("Casted float: %-g\t\t0x", input2);
	for (int i = 0; i < sizeof(float); i++)
		printf("%02X", *(((unsigned char *)&input2) + i));
	printf("\n");
	return 0;
}

You can technically pull this off but it's super hacky, may not work on all systems, and never recommended:
scanf("%g", &input1);
printf("%g\n", *((float *)&input1));
Jon McKee 14-Jul-20 3:38am View
   
Yea, this was a really good question. I learned something as well :)
Jon McKee 14-Jul-20 3:36am View
   
EDIT: Nvm, I get what you mean now CPallini. By adding the override in the derived you allow overloading to properly take place again since both functions are in the same scope.
Jon McKee 6-Jul-20 18:53pm View
   
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics

Start there. If you run into specific issues people here can help you out.
Jon McKee 3-Jun-20 21:46pm View
   
"Can't be uninstalled." I've never heard those words used for a non-malware application. My answer would be "I sure hope not."
Jon McKee 29-May-20 2:18am View
   
If I understand what you're asking and you're forced to use the given code, you can't do it with just ptr2. You'd have to either:
1) Define some termination value for the array (ex. always have an extra value at the end of the array that's equal to null). This would let you iterate through the array until you hit null (end of the array).
2) Add another parameter to findtarget that's the size of the array.
3) Reference the name of the whole array from the function like what you're doing in the code above (sizeof(fruit)/sizeof(fruit[0])).
Jon McKee 16-Mar-20 4:29am View
   
+5 Excellent tip with the explicit columns!
Jon McKee 10-Mar-20 6:44am View
   
Not sure I can help you there. I'm not very familiar with the google maps api. You probably should either post a separate question or update this one with whatever error or other information you're getting back from the google maps api. I'm sure someone around here is familiar with it and may know what's going wrong.
Jon McKee 10-Mar-20 6:29am View
   
Is it a single-schema database? If it worked with the schema there why remove it? Never hurts to be specific even if there is only one schema.
Jon McKee 10-Mar-20 6:11am View
   
"'lat:' '{0}'," should be "'lat': '{0}',". The single quote is in the wrong spot.

I also notice that the way you're concatenating the objects, you will end up with an extra ',' at the end. Ex: [ { .... }, { .... },]. So you might need to delete that last character before doing markers +="];".

Something like this should work:
let commaIndex = markers.lastIndexOf(",");
if (commaIndex > 0) {
  markers = markers.substring(0, commaIndex);
}
Jon McKee 10-Mar-20 5:40am View
   
What does ViewBag.Markers contain? It looks like it's an array, in which case I'm pretty sure you don't need @Html.Raw() because all that does is prevent the default Razor encoding for strings from happening by wrapping the non-encoded string in an IHtmlString. I'm actually not sure what happens if you pass it a non-string.
Jon McKee 9-Mar-20 19:44pm View
   
Haha, indeed. That is a much more useful error message 👍
Jon McKee 1-Mar-20 1:33am View
   
The query and what DB it is would help. Could give COLLATE Latin1_General_BIN a try in the meantime. Your issue is probably a character range specifier like c-e which under the Latin1_General_CS_AS rules includes upper case C and D (alphabetically sorted).
Jon McKee 29-Feb-20 22:48pm View
   
I think I may know what's going on, try this (works for me in the browser; explanation below):
let findShip = function (targetShip){    
  return cruiseLines.find(function (cruiseLine){        
    return cruiseLine.shipName.includes(targetShip);    
  });  
};

So I think this may have to do with type coercion. So the function that is passed into find should return a boolean to indicate that the value to return has been found. In the original code below, I've put the return types in brackets to illustrate:
let findShip = function (targetShip){    
  return [object] cruiseLines.find(function (cruiseLine){        
    return [string] cruiseLine.shipName.find(function (ship){            
      return [boolean] ship === targetShip;        
    });    
  });  
};

So what I'm used to with JS is that '', 0, -0, null, undefined, and NaN all convert to the boolean value false and everything else converts to true. But what might be happening for reasons I'm not sure of is that that second return type of string is converting to false for some reason, which is why the find keeps going.
Jon McKee 29-Feb-20 15:54pm View
   
I would try debugging the code then: https://code.visualstudio.com/docs/editor/debugging

I can't reproduce the issue and I don't have VSCode.
Jon McKee 24-Feb-20 22:31pm View
   
Where are you testing the Javascript? I'm using my browser console and it worked fine for me when I tested it just now.
Jon McKee 24-Feb-20 20:26pm View
   
Uh, my dude. You just posted your username and password. I'd highly recommend removing that and changing that password.
Jon McKee 23-Feb-20 3:02am View
   
Maybe I'm being dense but doesn't tblTable.removeColumn(tblTable.getColumnModel().getColumn(0)); delete txtNo? What exactly do you mean by "when I start to type the variable txtNo disappears"?
Jon McKee 2-Feb-20 2:25am View
   
100% this. Debugging is such an important skill and it's a shame it's never really given the time it deserves either in books or college.
Jon McKee 2-Nov-18 1:38am View
   
I don't use VS-Code, but apparently it only supports .NET Core projects (reference). Since WCF requires the full functionality of the .NET framework, you'd have to figure how to achieve that. Is there a hardware limitation that prevents you from using VS Professional (or Community)?
Jon McKee 28-Apr-18 23:29pm View
   
Make things. It sounds stupidly simple but I'm serious. Make things. Come up with an idea, even if it's been done before, and make it. Doesn't matter what language or if it's super simple like a calculator. The biggest secret no one will ever tell you is all languages are basically the same. Sure some are tailored for specific purposes but there's an enormous amount of "sameness" and topics that translate between languages - just different syntax and maybe a catch here and there. The reason people suggest languages like C# to start with is because it's popular and attempts to prevent you from shooting yourself in the foot. Something that a language like C++ gladly lets you do.

At the end of the day a language is just a set of tools. The important part is to develop your problem-solving skills and get comfortable with solving problems using those tools. It sounds like you're on the right path and Code Complete is a great book. If you're interested in web development the site FreeCodeCamp has an awesome free guided program to get you started there. It also has algorithm challenges I absolutely adore. Cheers!
Jon McKee 31-Mar-18 15:10pm View
   
Using this kind of approach, Parallel.For would be easier and handle the optimal parallelism for you :)
Jon McKee 28-Mar-18 3:30am View
   
Why? Escape sequences in string literals are standardized for a reason. If you really must (I vehemently recommend not), you can use the Split overload taking a string array. string[] Record = value.Split(new string[] {"\\tab"}, StringSplitOptions.None);

EDIT: Also the error is because '' indicates a single character but '\tab' doesn't translate to a single character. It translates to "<tab>ab".
Jon McKee 23-Mar-18 16:15pm View
   
True, haha. I was more footnoting because "basic and bad" and "better but harder" feel like general statements. ToInt32 never stops being "basic" even when it's good to use :thumbs_up:

I'm still trying to figure out whether they mean "12 + 1212 + 121212", "12 + 12^2 + 12^3", or "12 + 2*12 + 3*12".
Jon McKee 23-Mar-18 4:00am View
   
Griff: "...Convert.ToInt32 (basic and bad) or int.TryParse (much better, but harder to use)."

They have different meanings to me. Convert.ToInt32 is used when you expect success (failure is exceptional) while Try patterns are used when failure is expected occasionally and specific failure information isn't needed.
Jon McKee 19-Mar-18 16:52pm View
   
The first problem is probably because of casing. Your property is courseName on Cours. I always Pascal-case property names so I wrote it CourseName :P

Not sure on the second issue. LINQ to Entities can be touchy with select statements. It might be complaining if Cours doesn't have a public default parameterless constructor.
Jon McKee 19-Mar-18 16:38pm View
   
Glad to hear you figured it out! Binding can be a pain sometimes.
Jon McKee 17-Mar-18 7:14am View
   
Nicely explained +1
Jon McKee 5-Mar-18 0:17am View
   
I added a purely async suggestion in my original solution. If PLINQ isn't helping no need to complicate code with it :)
Jon McKee 3-Mar-18 23:48pm View
   
I can't really help unless I know objectively that's the case. Does the exception say that? Post the relevant breakpoint information for _id, preferably a stack trace/exception, and indicate which line of code the trace points to since I can't see your line numbers. I most likely won't be able to debug an async problem through chat though. Have you tried just using PLINQ (the first example in my post) without asynchronous programming on top? It should help by itself if you have a large row count.
Jon McKee 3-Mar-18 23:03pm View
   
Is the error coming from the Query and if so which part - the constructor call or the query execution? If not, is it String.Format? If so, could you put a breakpoint before Task.Run and on string _wiql. Check the value of _id. If it's fine on the first breakpoint but not on the second, try moving the string _wiql definition to the start of the function instead of inside the Task.Run. Debugging is incredibly difficult without stack traces, the full relevant code, and knowledge of the specific libraries used like Microsoft.TeamFoundation.WorkItemTracking.Client. I do have a new suggestion up top though after reading about Query for after debugging.
Jon McKee 3-Mar-18 22:57pm View
   
Deleted
Is the error coming from the Query and if so which part - the constructor call or the query execution? If not, is it String.Format? If so, could you put a breakpoint before Task.Run and on string _wiql. Check the value of _id. If it's fine on the first breakpoint but not on the second, try moving the string _wiql definition to the start of the function instead of inside the Task.Run. Just a thought, debugging is incredibly difficult without stack traces, the full code, and knowledge of the specific libraries used like Microsoft.TeamFoundation.WorkItemTracking.Client. I do have a new suggestion up top though after reading about Query after debugging.
Jon McKee 3-Mar-18 12:41pm View
   
What error are you seeing? If _id is blank at the start of the function I'd check to ensure r["Storyid"] exists. I'd also try to see if you could batch execute the queries for each row. Each row select triggering 3 separate DB queries isn't exactly a great idea if performance is an issue.
Jon McKee 27-Feb-18 14:21pm View
   
You beat me to it. Have a hypothetical +1
Jon McKee 17-Feb-18 1:25am View
   
Disclaimer: I have no solution or information to add to your problem so ignore the rest of my statement if that's all you're after.

One of the fundamental principles of modern operating systems is the default separation of processes - both in memory and access. The two recent major exploits (Spectre and Meltdown) both break this contract which is why freaking out was the common reaction. Without explicit permission by other applications for your application to extract their data (screen position, data entered, etc) or "hacks" I'm not sure this is possible. Even if possible, I'm not sure it's a net positive as it would represent a real, tangible problem.
Jon McKee 16-Feb-18 14:51pm View
   
Why not iterate over the list manually, remove matching elements, then compact the array. Much like the existing remove function does in your code except multiple times instead of once. If this is a low-level course the point is to teach problem solving and LINQ sort of ruins the lesson :P

The reason why LINQ isn't working though is RemoveAll is defined for List<T> not basic arrays (IEnumerable<T>). You'd have to create a list from your array.
Jon McKee 16-Feb-18 1:04am View
   
LINQ is one way to go. That would definitely work if 1 represents whatever item needs to be removed :)

EDIT: Also never be afraid to just try something and see if/how it works. I actually have a solution called "RandomTests" on my box that I use just to mock up and test random questions that pop up while working on projects :)
Jon McKee 15-Feb-18 23:46pm View
   
I'm a little confused by your program. It seems like you're trying to count the numbers that are divisible by 10 with a function that simply checks to see if a single number is divisible by 10. Also you don't need the ternary ?: operator. x % 10 == 0 is a boolean condition already because of the equality operator ==.
Jon McKee 15-Feb-18 23:37pm View
   
So this is obviously homework so I'm not posting code but consider this: a RemoveAll method essentially just loses all references to the data in the array; how would you accomplish that?
Jon McKee 31-Mar-17 15:26pm View
   
Besides the stack overflows? Hehe. I figured out the area that's causing the overflow but was too tired to figure out what was wrong so I went to bed. Will be fixing it up today :thumbsup:
Jon McKee 31-Mar-17 5:35am View
   
Will do! I doubt any of the solutions will be "ground-breaking" (O(n) is about the best you can ask for) but it could still lead to some very interesting solutions!
Jon McKee 2-Mar-17 20:08pm View
   
Actually I was already planning on using WPF for my solution before I saw yours :) Wanted a project with graphics.
Jon McKee 2-Mar-17 15:50pm View
   
Nice :thumbsup: I decided on a WPF solution this morning I'll be working on tonight :)
Jon McKee 1-Mar-17 2:11am View
   
Unfortunately that's a tough question to answer without your code and hardware. I don't have experience with a program with that many processes since I avoid that in design.

That being said here's what I'm thinking: your processes rarely block. That's an assumption I'm making based on what I've read. You have at minimum 120+ processes all clawing for processor time. CPUs are better designed for blocking tasks. Running >2x the available cores in constantly active processes is going to guarantee context-switches at every opportunity (probably time-slice timeout since I assume your processes are on the same priority). This is gonna eat up processor time with kernel tasks since it needs to both switch the thread context and process context.

Again, I don't have your setup, but from my point of view the program needs a redesign focusing on minimizing processes using AppDomains and threads while possibly (bonus points) minimizing the need on these with the async-await pattern (TAP) where applicable.

EDIT: Of course all this could be moot. It could be an issue somewhere else like the SQL server. It could be a lot of things. I'd still focus on tackling the scaling issue from a design point of view. Even if you fix this specific issue now, what happens if you need to scale to 300 or 400? Cheers :thumbsup:
Jon McKee 26-Feb-17 3:10am View
   
You probably don't need to set the threads manually. It defaults to the number of cores and ramps up from there. The default ThreadPool though isn't really meant for long-running or heavily-blocking tasks. My suggestion would be something simple and lightweight that spins up your own Threads or you may want to use Tasks. That being said I still think analyzing the system and determining what exactly is causing the problem is the best idea before any major code changes.
Jon McKee 25-Feb-17 3:56am View
   
Quick question: What's the CPU usage like when you start 50 compared to 100 compared to 200? Having that low-end 50 could be useful in determining if it's a scaling issue with the code.
Jon McKee 24-Feb-17 15:09pm View
   
Well said in that article :thumbsup:
Jon McKee 24-Feb-17 14:42pm View
   
Just limit it to one solution per person =P Let's see if Graeme can fit all those solutions coherently into a single post, hehe <3
Jon McKee 14-Feb-17 17:08pm View
   
I know there's an implicit ENDLOCAL at the end of a batch script but it still bugs me :P Hehe, anyways, good job on... 4 solutions across 5 languages? Wow x_x
Jon McKee 10-Feb-17 1:40am View
   
MVC is just a design paradigm to help decouple the view and model with a controller. GOF are patterns that solve problems which will generally be in the model part of an MVC project. Use a tool when you need a tool. Don't over-architect your solution if you don't need to as it will only cause problems in the future.
Jon McKee 10-Feb-17 1:36am View
   
Jon McKee 10-Feb-17 1:34am View
   
Jon McKee 9-Feb-17 15:52pm View
   
+5'd, well said! Just wanted to point out CORS is only gonna save you against some CSRF attacks and other methods like STP should also be considered depending on need. OWASP CSRF Cheat Sheet.
Jon McKee 6-Feb-17 20:18pm View
   
What? "Updated + a smiley face"? I was just responding to say I updated my response after reading your comment. The new code above should work within your requirements.
Jon McKee 6-Feb-17 19:15pm View
   
Updated =)
Jon McKee 30-Jan-17 4:41am View
   
Then ask a question. Are you pmcm under a different name? You're asking a question as an answer to a question another member has asked. Do you really expect experts on kanbanize to respond to a question related to C#, ASP.NET, and HTTP?
Jon McKee 30-Jan-17 4:32am View
   
??? I have no issues accessing the links on that page. I've never used kanbanize before, but you might need to sign-up before you get a guid to access the service. Unless you meant "guide" in which case that link has everything kanbanize offers...
Jon McKee 30-Jan-17 4:16am View
   
I added to my response if you wanted a more technical and less "this is how you use it" explanation =) I'm glad you're so interested in different technologies! The world needs more of that =D
Jon McKee 30-Jan-17 4:10am View
   
This has nothing to do with computers except using your browser. If you have a question then post a question. Do not post a question as an answer to an existing question. Not only is that rude but you won't get any responses. Also kanbanize already has guides for using its API.
Jon McKee 30-Jan-17 4:03am View
   
JSONP is basically just JSON that is wrapped in a function call and embedded as a script to bypass CORS. You can use JSONP if the service supports returning data as JSONP instead of plain JSON. An excellent summation can be found here. Or here if you want a more technical explanation.
Jon McKee 30-Jan-17 3:53am View
   
Why are you posting a question as an answer to a question? Seriously...
Jon McKee 30-Jan-17 3:19am View
   
Ah, CORS. This is why JSONP was created =)
Jon McKee 30-Jan-17 2:08am View
   
Updated the solution =)
Jon McKee 29-Jan-17 23:31pm View
   
This is a good article. If you're already familiar with WCF I'd just go that route unless you know Web API. Web API (and REST in general) requires less configuration than WCF (and SOAP) so it's easier to work with imo.
Jon McKee 28-Jan-17 4:12am View
   
Not to mention the jump from val1 to val7. Whatever happened to descriptive variables? Well done though, this seems plausible as the issue despite the lack of any description of the types involved.
Jon McKee 28-Jan-17 3:49am View
   
Very good point! I totally missed the comma instead of "AND". 5ed!
Jon McKee 28-Jan-17 3:44am View
   
I already mentioned SQL injection in my first response =P "user123'; drop table user_details; --" =D Raw password storage I did fail to mention though. Also good point about the actual SQL, I totally missed that it was a comma and not an "AND" :thumbsup: I'm too accustomed to LINQ =(
Jon McKee 28-Jan-17 1:34am View
   
There are some good suggestions here but I must ask: do you require WCF? WCF is very useful when you need a service to handle TCP, pipes, etc. If you only require HTTP consider using a REST service like an ASP.NET Web API project. Much simpler to configure and use compared to WCF.
Jon McKee 28-Jan-17 1:30am View
   
Beyond Peter Leow's suggestion which is probably the issue you're having, could you post relevant code? Without seeing the code we can't point you to the exact area the code is modifying the pointer incorrectly.
Jon McKee 28-Jan-17 1:17am View
   
Beyond using while instead of if (unless that's explicitly what you want) and what I mention above, I honestly don't see an issue with this code. I don't see any issues with your quoting. Have you put a breakpoint on the line that throws the error and examined what the SQL query and related objects look like?
Jon McKee 28-Jan-17 1:03am View
   
I don't see any obvious problems from a glance. What line causes this error? Have you done any debugging? What were the results? Obvious problems beyond concatenating an SQL query, that is.
TextBox1.Text = "user123'; drop table user_details; --";
Jon McKee 27-Jan-17 18:40pm View
   
He specified VB. Didn't say anything about just BASIC ;)
Jon McKee 27-Jan-17 16:43pm View
   
Perl is considered C-based but F# isn't? That's a little odd tbh. If anything Perl has less in common with C than F#. Also that link includes B which was the precursor to C which I find baffling.
Jon McKee 27-Jan-17 3:47am View
   
C# Tutorial. Start here.
Jon McKee 26-Jan-17 23:56pm View
   
Talk to your teacher or classmates. School is for teaching you how to learn and the basic skills you need to succeed. If you simply ask for answers you will learn neither of those skills.

Start here: Percentages. Then review basic conditional expressions in C#.
Jon McKee 20-Jan-17 3:00am View
   
I'm an e-sports fan so I'd try to go to Seoul around time for the World Championships of LoL, SC, or similar ;)

EDIT: Also, wow, you've worked all over the place o_O
Jon McKee 20-Jan-17 2:57am View
   
Haven't yet but it's on the list! I'd love to visit South Korea as well. Love the language even though it's really hard to pronounce some words as a native English speaker and I don't know any native speakers.
Jon McKee 20-Jan-17 2:52am View
   
That's awesome! I miss the Japanese community where I went for college; Iida-sensei was a great teacher. My Japanese has gotten pretty rusty over the years because of where I live now in mid-west US.

I used to know a good bit of Tagalog (Filipino) and some French as well but I've basically forgotten both of those :(
Jon McKee 20-Jan-17 1:01am View
   
Oh yea, I just didn't see shi/shichi in your array and was making a comment :) I took 4 years of Japanese and can speak it... "ok" haha. There's a lot of little "gotchas" just like English but more centered around how words combine.
Jon McKee 19-Jan-17 14:23pm View
   
Yon (4) and nana (7) can also be shi (4) or shichi (7). Kyuu (9) can also be ku (9) as well though I don't think I've ever heard someone use ku. Depends on the context.
Jon McKee 14-Jan-17 4:27am View
   
I'd like to point out that you don't have that level of granularity with ANY modern OS afaik. The best you can hope for in Windows is abusing the Real-Time/Time-Critical levels of process/thread priority. Even then you can not guarantee the scheduling.
Jon McKee 13-Jan-17 4:03am View
   
I'd try to help, honestly, but I'm still not sure what you're after. Addition of 8 and 4,4 would yield 16. Plus I'm not sure on the rules regarding what should be added to array #1 in what position and what should be ignored. For example, why is 7 not modified by array #2? From my standpoint, there seems to be no relationship between modified values and the index in array #2.
Jon McKee 13-Jan-17 3:54am View
   
Deleted
Unfortunately I'm in the US where a degree requires $$$$ even considering subsidized government loans. I'd like to complete my education at some point but to be honest at this point it'd just be an exercise in patience considering I'm so far beyond what college teaches. Hoping for those rare companies that value ability over credentials. I'll keep trying though!
Jon McKee 13-Jan-17 3:36am View
   
His response gives you all the resources you need to send or receive messages via a GSM modem. The first link even links to a CP article. What more do you want? We are here to guide you, not to do your work for you.
Jon McKee 13-Jan-17 3:26am View
   
Why think when you can just ask CP or SO? :laugh:
Jon McKee 13-Jan-17 3:25am View
   
You have no idea considering I can't get hired due to a lack of a college degree despite my knowledge and nearly 5 years experience in the industry.
Jon McKee 13-Jan-17 3:15am View
   
Let's be honest. No one in QA has googled even the basic terms related to their question. Most are vampires which have undeserved jobs relying on others to keep their paychecks rolling. OP asks for GSM then says GSM isn't adequate in his response.
Jon McKee 13-Jan-17 3:12am View
   
Gave him the benefit of the doubt, but I can't agree more with this. Homework is designed to make you think. Without the ability to think you are no more than a copy-paste bot for which google could do your job.
Jon McKee 13-Jan-17 3:04am View
   
Your output for array #1 and #2 are vastly different. Array #1 to modified array #1 makes sense, but from array #2 to modified array #2 makes no discernible sense. Could you elaborate on the conversion between array #2 and modified array #2?
Jon McKee 13-Jan-17 1:09am View
   
You are describing the way in which many operating systems already schedule tasks onto the CPU. Given a specific platform such as Windows, you can use SetPriorityClass and SetThreadPriority to ensure a priority for your code's tasks though that is discouraged unless you have dedicated systems. Other than that, you can not guarantee your code will run every X milliseconds due to kernel-level scheduling. If that amount of scheduling is necessary, you need to create your own quasi-OS that runs on top of the hardware. That is an extremely complex topic that is far beyond what a QA answer will give.
Jon McKee 12-Jan-17 4:33am View
   
I mean more what object they're defined on. Is the PortSettings property on the same object that oBackgroundGrid is defined on? The definitions look fine - it's probably an issue of where they're defined. WPF can be a hard thing to debug without the full code because so many things can go wrong or get overlooked.
Jon McKee 12-Jan-17 4:27am View
   
If you mean the Convert.ToInt32 methods, then no. DateTime stores the invidivual year/month/day as an int.

Side Note: There is a slight difference between Convert.ToInt32 and Int32.Parse. Convert returns 0 instead of throwing an exception on an invalid argument.
Jon McKee 12-Jan-17 4:17am View
   
Agreed! Though I would note PLINQ can help for certain situations if you really know what you're doing.
Jon McKee 12-Jan-17 4:13am View
   
My thoughts exactly. Seems like age might be stored as a "MM/DD/YYYY" string.
Jon McKee 12-Jan-17 4:12am View
   
Where is PortSettings defined? From the error, the binding doesn't seem to be able to locate this property. Would help to see the relationship between PortSettings and where this code is defined.
Jon McKee 11-Jan-17 1:56am View
   
Too kind +5, though I do understand the drive to help :)
Jon McKee 11-Jan-17 1:26am View
   
You have already posted this here. Either update your original question or post a response to an answer already given. You have given little effort other than copying what a response gave you. Please attempt the solution on your own and post relevant code - we are not here to do your job for you.
Jon McKee 11-Jan-17 1:17am View
   
Could you explain what the SQL command is trying to accomplish? I'm particularly interested in "WHERE OrderID IN (SELECT OrderID FROM OrderDetails WHERE ProductID = 1) AND OrderDetails.ProductID <> 1." Is this SQL attempting to find ProductName/OrderDetails combinations that don't have the proper data? The LINQ isn't too hard but all mock-ups I attempt return nothing because of this statement. You filter by OrderID's that have ProductID = 1, but then subsequently filter on ProductID != 1. This seems counter-intuitive unless errors are expected.
Jon McKee 9-Jan-17 2:44am View
   
Am I the only one wondering what on Earth a MomDad and DadMom string is? Is that just referring to string re-ordering?
Jon McKee 7-Jan-17 0:11am View
   
Best of luck on the project! I've been meaning to learn Powershell since I've heard it's basically Batch++ so that version is very interesting to me =)
Jon McKee 7-Jan-17 0:04am View
   
You've got another week, no excuses! Lol =)
Jon McKee 6-Jan-17 23:57pm View
   
I wish I could upvote a comment. This is exactly the solution.
Jon McKee 6-Jan-17 23:56pm View
   
I think that's up to us this time around.
Jon McKee 6-Jan-17 23:54pm View
   
Oooo, do an F# version next! =D (just a jest =P)
Jon McKee 6-Jan-17 23:51pm View
   
No exception, it's a quirk of Read() if you were curious :)
Jon McKee 6-Jan-17 23:48pm View
   
There's no error message. It's a quirk of Read() and why MSDN recommends not using it anymore :)
Jon McKee 6-Jan-17 14:13pm View
   
Thank you for making me laugh so hard I got weird looks from people :thumbsup:
Jon McKee 6-Jan-17 0:07am View
   
"Bonus points awarded for use of an interesting language." "only if he promises never to do that again." :( Ok... :P
Jon McKee 5-Jan-17 16:34pm View
   
I'm sure you realized this by now but if not, WFA = Windows Forms Application :)
Jon McKee 5-Jan-17 16:33pm View
   
There are still companies running XP AND IE6. Makes me a little nauseous tbh.
Jon McKee 4-Jan-17 13:59pm View
   
I don't have tons of experience with WinForms but I'm guessing you're using an ElementHost to host a WPF UserControl or similar? You may have to traverse the hierarchy using ElementHost.Parent. It would really help to have more of the code. What you've posted doesn't show anything relevant such as the code which hosts the xaml or the xaml itself so I doubt you'll get any meaningful responses.
Jon McKee 4-Jan-17 2:02am View
   
No problem! :)
Jon McKee 2-Jan-17 2:15am View
   
You literally give no basis for comparison. You could replace C# with any noun in existence and this question would be equivalent. You gotta give some example for comparison or people won't even know if you understand what a variable or function/method represents.
Jon McKee 30-Dec-16 20:29pm View
   
Not sure who gave you the one star, I think your first two examples are fine at a glance, but your 3rd example has a major flaw.
  lock (_instance) ; //You're releasing the lock before checking the unsafe code
  if (_instance == null)

Now in practice this might help as the delay between one thread releasing the lock and the next thread picking it up might allow the first thread to fully execute the singleton creation, but this is not a guarantee. You should be using double-check locking instead.
  if (_instance == null)
    lock (_instance)
      if (_instance == null)
        return new Singleton();
      else
        return _instance;
  else
    return _instance;

In addition, you should also not be locking on the _instance. You never want to lock on something that is shared because you could run into deadlock scenarios. Create an object like private static readonly object _instanceLock = new object(); and lock on that.

I'd also like to point out you never assign the new singleton creation in examples 1 and 3. You simply return it ^^
Jon McKee 28-Dec-16 21:20pm View
   
Parse on ". Assuming address isn't the first field and is the only field that contains your delimiter it will be the 2nd token. Then parse tokens 1 and 3 as necessary. Could also use regular expression balancing groups but that's a headache if you aren't absolutely certain of the format which you seem to not be.

Another option is to simply use a delimiter that isn't a symbol that appears in your data like Hin Wai suggested below.
Jon McKee 18-Dec-16 15:05pm View
   
Just wanted to point out that the 2pi solution is called the "Winding Number Algorithm" if you were curious =)
Jon McKee 17-Dec-16 18:22pm View
   
Agree with everything Griff said :thumbsup:
Jon McKee 17-Dec-16 13:34pm View
   
Ok, I think I know what's going on here. So this is one page in a larger application. When this page is created you're passing an ID for your defendant which is both the primary key for your defendant and a foreign key for your witnesses, retrieving the defendant data, and updating the DataContext for one of the page controls that displays that data. All good so far.

So now you have a page setup for a defendant and you want them to be able to add witnesses. So there's an "Add Witness" button somewhere on the page that is handled by AddWitness(). This event handler is responsible for setting up the witness view and passing the ID for this defendant so that ID can be used as the MasterID (foreign key) when creating new witnesses? Correct?

If so, all you need to do is propogate the constructor ID down to the handler. My example above actually did that:
//Add a property to your page
public int MasterID { get; private set; }

public DefendantView(int ID)
{
    InitializeComponent();
    GetDefendantById(ID);
    //Set that property in your constructor
    MasterID = ID;
}

private void AddWitness(object sender, RoutedEventArgs e)
{  
    //Pass the property to your witness view
    this.NavigationService.Navigate(new AddWitnessView(MasterID));
}
Jon McKee 17-Dec-16 0:36am View
   
Check the result only? I mean, as long as they submit code that reaches the valid conclusion what's the problem? To force a specific methodology would be both tedious to verify and stifle creativity.
Jon McKee 15-Dec-16 4:05am View
   
I'm still not sure this is what you want from your previous post here but you've optimized this as much as you can expect. The calculation of NetPayable demands an iteration over PatientBillDetails and subsequently an iteration over the summed value.
Jon McKee 15-Dec-16 3:46am View
   
Honestly I can't. Multiple PBD produce multiple groupings with the join of VD and PB (or the join of PBD and PB with VD). Unless there's a way to filter the PBD based on some criteria you'll always have this problem. The example code you gave above that ignores PBD has optimizations (preventing the allocation of unnecessary objects), but I'm not sure it accomplishes what you want. A simple solution would be to divide the result by 2 but if the PBD aren't equal this solution doesn't work. I just don't have enough information on the purpose of this task to give you an adequate answer beyond what I already have :(
Jon McKee 15-Dec-16 3:09am View
   
Ah. Unless I know what the purpose of multiple bill details is I can't really help. Do you choose the lowest of the possible bill details? Highest? An average? Unless you choose one or use an algorithm to combine them into a single value you'll always get multiple groupings.
Jon McKee 15-Dec-16 3:08am View
   
You don't need to create an anonymous type for one.
group PB by VD.VisitCode into data
would avoid the allocation of a new type PB times for each grouping of VD.VisitCode.
Jon McKee 15-Dec-16 2:40am View
   
Isn't this intended behavior? You have multiple entries for the bill details, so joining them into the patient bill will produce a result {PB1, PBD1}, {PB1, PBD2}, {PB2, PBD3}, {PB2, PBD4} for each of the detail:bill pairs. If not I'm not sure what the purpose of multiple PatientBillDetails entries is. If you could clarify that I may be able to help :)
Jon McKee 14-Dec-16 20:38pm View
   
As Andy mentioned, could you post your data table classes? The code posted should work fine assuming it's setup correctly.
Jon McKee 14-Dec-16 9:54am View
   
Everything he needs is already right here. The only thing new would be Sum() and Take(). I'll let him figure that one out on his own =)
Jon McKee 13-Dec-16 21:05pm View
   
Gotta farm that rep :laughing:
Jon McKee 12-Dec-16 0:33am View
   
Lol, I was bored =S Also I see a lot of groupby/orderby confusion with a computed value like a count and all that so it may be useful to have an example laying around I suppose.
Jon McKee 11-Dec-16 3:23am View
   
+1, this is why you have developers with PhDs that can't even solve FizzBuzz problems... =(
Jon McKee 11-Dec-16 2:48am View
   
Very true. Would probably improve if the challenge is cross-posted in the Lounge like the first one.
Jon McKee 11-Dec-16 2:46am View
   
Looks like a legitimate question, so please, can you wrap your code (instead of your text) in pre tags for VB? This is literally unreadable to me and probably anyone that views this question. I haven't looked at the code but in Vista and later versions of Windows you need administrative privileges to edit the registry.
Jon McKee 11-Dec-16 2:30am View
   
I love that there are no votes on any solution =D Everyone thinks their solution is the best (I'm no exception).
Jon McKee 10-Dec-16 21:43pm View
   
1) Yep. A ThreadPool is just a class that manages background threads.

2) Sorta? I've never seen the internals but I imagine ThreadPool uses the Thread class instead of re-inventing the wheel. A thread is simply a lightweight process. It's a separate execution path from the default execution path (commonly called the main thread) automatically started by the main process. These execution paths have to be run by the CPU. Cores can run multiple threads - it depends on the technology. If I remember correctly an i5 with 4 cores can run 4 threads (2 per core with hyper-threading) concurrently. There's a lot of other things that come into play with this though like context-switching between threads when there's a delay like I/O which means you can effectively run more.

EDIT: Misread part of #2, fixed answer accordingly.
Jon McKee 10-Dec-16 11:58am View
   
Definitely have me beat on memory usage (21 MB), but I've got ya on speed. I haven't posted it because there's no point but I modified my algorithm to use uint to double the number range. I can run 1,000,000 numbers in the range 0 <= n <= 4,285,200,000 in ~155 ms =)
Jon McKee 10-Dec-16 11:38am View
   
Especially considering the common approach to calculating LCM uses the GCD in the divisor/denominator. 0 would be no bueno.
Jon McKee 9-Dec-16 18:43pm View
   
{ 5, 7, 20, 40 } breaks it and returns 0 instead of 1. The algorithm assumes the list has a common GCD greater than 1 when it may not according to the challenge =) EDIT: Clarified "greater than 1", 1 is a GCD as PIE pointed out =)
Jon McKee 6-Dec-16 18:02pm View
   
I'm guessing since it involves trig it's a conversion from degrees to radians.
Jon McKee 3-Dec-16 20:14pm View
   
I want to be mad because of how true this can be but I can't stop laughing. Bravo /clap
Jon McKee 26-Nov-16 20:55pm View
   
I see what you did there /golfclap :)
Jon McKee 26-Nov-16 19:33pm View
   
Unless the question is "what is a nonvenomous snake indigenous to Africa, Asia, and Australia with some of the largest snake species currently known in its genus." ;D
Jon McKee 26-Nov-16 19:12pm View
   
Can't wait for another one. I love this sort of stuff =D