instruction
stringlengths
0
30k
|sql-server|performance|indexing|
No, it's not, use the Stopwatch (in System.Diagnostics) Stopwatch sw = Stopwatch.StartNew(); PerformWork(); sw.Stop(); Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds); Stopwatch automatically checks for the existance of high-precision timers. Worth mentioning is that D...
No, it's not, use the [Stopwatch][1] (in System.Diagnostics) Stopwatch sw = Stopwatch.StartNew(); PerformWork(); sw.Stop(); Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds); Stopwatch automatically checks for the existance of high-precision timers. Worth mentioning is t...
Chalk this one to lack of experience, but during my seven-year stint as a code monkey I've *never* actually seen anyone make the mistake of not adding braces when adding code to a block that doesn't have braces. That's precisely *zero* times. And before the wisecrackers get to it, no, the reason wasn't "everyone al...
As you already mentioned, those terms mean different things in different stacks - there is no one right generic answer for web services.
You seem to be starting by assuming that your problem is download size - that may not necessarily be the case. You should do some experimentation with your ASP.NET site to determine if there are areas in your code which are causing undue delays. If it turns out that download size is not your problem, you'll need to fin...
@Thomas Owens - the person in that cafe after you is going to be proper befuddled. I guess to be good on both you'd have to alternate all the time. I have enough trouble switching between my laptop and desktop keyboards :-)
@Thomas Owens - the person in that cafe after you is going to be proper befuddled :-D I guess to be good on both you'd have to alternate all the time. I have enough trouble switching between my laptop and desktop keyboards :-)
> I've never used a public computer, but carry a keyboard and(/or, if you are good enough) just change the settings on the machine. There's a special place in hell for people that change keyboard mappings on public computers.
For a group of 6 people that will be making "every now and then" edits, the built-in wiki will be fine.
> I can post the inner loop code, but I'm not sure if SO is supposed to be generic or specific. I'll let the mob decide. The code you post as an example can be as specific as you (or your boss) is comfortable with - more often than not, it's easier to help you with more specific details.
If the inner loop code is a reasonable length, I don't see any reason you can't post it. I think Stack Overflow is intended to encompass both general and specific questions.
I try to, yes. They do indeed help maintainability and readability of your code. However, there are people who do abuse them, usually (from what I've seen) by forcing a system into a pattern that doesn't exist.
Here are some caveats I came across that will vanish if you use a wiki other than Sharepoint. Sharepoint lets you create tons of separate wikis, but I'd recommend having one big wiki for everything. My company made a bunch of little wikis for each project/feature, but only admins can create the individual wikis, so ...
Have your service listen to 127.0.0.1 on a predefined port with a plain old TCP stream socket. Connect to that port from your desktop application. It's dead simple and it's completely cross platform.
How to add an event to a class
|class|design|
Say I have a class named Frog, it looks like: public class Frog { public int Location { get; set; } public int JumpCount { get; set; } public void OnJump() { JumpCount++; } } I need help with 2 things: 1. I want to create an...
|class|design|c#|
|c#|design|events|class|
How do I derive a Voronoi diagram given its point set and its Delaunay triangulation?
|geometry|voronoi|delaunay|
I'm working on a game where I create a random map of provinces (a la Risk or Diplomacy). To create that map, I'm first generating a series of semi-random points, then figuring the Delaunay triangulations of those points. With that done, I am now looking to create a Voronoi diagram of the points to serve as a star...
I don't understand why this is a troubling problem. It could be solved in any number of ways. If you want to do a full object oriented enterprisey type thing, you could take any subset of the following solution: - Create an interface IProject which describes how other objects interact with a project. ...
As far as how to set up the DNS subdomain wildcard, that would be a function of your DNS hosting provider. This would be different steps depending on which hosting provider you have and would be a better question for them. Once you've set that up with the DNS host, from your web app you really are just URL rewriti...
Ok, it looks like there are a couple of issues here. As far as I can tell, there is no such thing as a "droppable" in mootools. This means your events like 'enter', 'leave' and 'drop' won't work. (These are events on the drag object) If you change those names to events that elements in mootools have (as in, DOM even...
> how on earth do one [...] implement the function that given zip code 12345, gets all zipcodes in 1 mile distance? Here is a sample on how to do that: [http://www.codeproject.com/KB/cs/zipcodeutil.aspx][1] [1]: http://www.codeproject.com/KB/cs/zipcodeutil.aspx
It seems like everyone is trying to find the Java way to do it like you're doing it in PHP, instead of the way it ought to be done in Java. Just consider each piece of your array an object, or, at the very least, the first level of the array as an object and each sub level as variables inside the object. The build a da...
As a junior programmer, I'm still trying to get into the habit of writing tests. Obviously it's not easy to pick up new habits, but thinking about what would make this work for me, I have to +1 the comments about code reviews and coaching/pair programming. It may also be worth emphasising the long-term purpose of te...
Two design approaches to consider The [essence](http://www.hillside.net/plop/plop98/final_submissions/P10.pdf) pattern The [fluent interface](http://java.dzone.com/news/factories-builders-and-fluent-) pattern These are both similar in intent, in that we slowly build up an intermediate object, and then create o...
Two design approaches to consider The [essence](http://www.hillside.net/plop/plop98/final_submissions/P10.pdf) pattern The [fluent interface](http://java.dzone.com/news/factories-builders-and-fluent-) pattern These are both similar in intent, in that we slowly build up an intermediate object, and then create o...
No, it's not, use the [Stopwatch][1] (in System.Diagnostics) Stopwatch sw = Stopwatch.StartNew(); PerformWork(); sw.Stop(); Console.WriteLine("Time taken: {0}ms", sw.Elapsed.TotalMilliseconds); Stopwatch automatically checks for the existance of high-precision timers. Worth mentioning is t...
> True. I didn't account for duplicate encodings. There are actually 252-1 NaNs for doubles and 223-1 NaNs for singles, though. :p Doh, forgot to subtract the infinities.
SQL Server 2005 and up offer MVCC as an option; it isn't the default, however. MS calls it snapshot isolation, if memory serves.
As [lassevk][1] pointed out, VBScript is not Visual Basic. I believe the only built in object in VBScript is the WScript object. WScript.Echo "Hello, World!" From the docs > The WScript object is the root object of the Windows Script Host > object model hierarchy. It never needs to be instantiated befo...
You may want to look into SQLite (http://sqlite.org/). All depends on your usage though. Concurrency for example is not its greatest virtue. But for example Firefox uses it to store settings etc..
MVCC can also be implemented manually, by adding a version number column to your tables, and always doing inserts instead of updates. The cost of this is a much larger database, and slower selects since each one needs a subquery to find the latest record. It's an excellent solution for systems that require 100% a...
Are you aware that the Access 2007 runtime can be downloaded for free? http://www.microsoft.com/downloads/details.aspx?familyid=d9ae78d9-9dc6-4b38-9fa6-2c745a175aed&displaylang=en
What about Microsoft's Visual Studio Express? http://www.microsoft.com/express/default.aspx SQL Server Express is also at that link...
Two design approaches to consider The [essence](http://www.hillside.net/plop/plop98/final_submissions/P10.pdf) pattern The [fluent interface](http://java.dzone.com/news/factories-builders-and-fluent-) pattern These are both similar in intent, in that we slowly build up an intermediate object, and then create o...
How about this: class TypedTuple: def __init__(self, fieldlist, items): self.fieldlist = fieldlist self.items = items def __getattr__(self, field): return self.items[self.fieldlist.index(field)] You could then do: j = TypedTuple(["jobid", "labe...
How about this: class TypedTuple: def __init__(self, fieldlist, items): self.fieldlist = fieldlist self.items = items def __getattr__(self, field): return self.items[self.fieldlist.index(field)] You could then do: j = TypedTuple(["jobid", "labe...
DSL's are good in situations where you need to give some aspect of the system's control over to someone else. I've used them in Rules Engines, where you create a simple language that is easier for less-technical folks to use to express themselves- particularly in workflows. In other words, instead of making them lea...
There are many design patterns beyond the simple that are used in "real world". Good example Stackoverflow uses the Model View Controller Pattern. I have used Class Factories multiple times in projects for my employer, and I have seen many already written projects using them as well. I am not saying every design pa...
Yes we do, it usually happens when we start designing something and then someone notices that it resembles an existing pattern. We then take a look at it and see how it would help us achieve our goal. We also use patterns that are not documented but that emerge from designing a lot. Mind you, we don't use them a ...
You should take a look at [Visual Studio Gallery](http://www.visualstudiogallery.com/), the *one stop shop for Visual Studio extensions*. Here you'll find quite a lot of extensions for Visual Studio in all categories, from intellisense and refactoring to designers and documentation builders.
I try to use patterns if they are applicable. I think it's kind of sad seeing developers implement design patterns in code just for the sake of it. For the right task though, design patterns can be very useful and powerful.
Yes, I use a lot of well known design patterns, but I also end up building some software that I later find out uses a 'named' design pattern. Most elegant, reusable designs could be called a 'pattern'. It's a lot like dance moves. We all know the waltz, and the 2-step, but not everyone has a name for the 'bump and scoo...
MVC is very well known so yes we use design patterns quite a lot. Now if your asking about the Gang of Four patterns, there are several that I use because other maintainers will know the design and what we are working towards in the code. There are several though that remain fairly obscure for what we do, so if I use...
I find the MVC pattern really useful to isolate your model logic, which can than be reused or worked on without too much trouble. It also helps de-coupling your classes and makes unit testing easier. I wrote about it [recently][1] (yes, shameless plug here...) Also, I've recently used a factory pattern from a base c...
As far as how to set up the DNS subdomain wildcard, that would be a function of your DNS hosting provider. This would be different steps depending on which hosting provider you have and would be a better question for them. Once you've set that up with the DNS host, from your web app you really are just URL rewriti...
As far as how to set up the DNS subdomain wildcard, that would be a function of your DNS hosting provider. This would be different steps depending on which hosting provider you have and would be a better question for them. Once you've set that up with the DNS host, from your web app you really are just URL rewriti...
I'd say that a dictionary is definitely the best way to do it. It's easily extensible, allows you to give each value a sensible name, and Python has a lot of built-in language features for using and manipulating dictionaries. If you need to add more fields later, all you need to change is the code that converts the t...
I'd say that a dictionary is definitely the best way to do it. It's easily extensible, allows you to give each value a sensible name, and Python has a lot of built-in language features for using and manipulating dictionaries. If you need to add more fields later, all you need to change is the code that converts the t...
I second FlashDevelop. You don't get the visual design stuff for the MXML, but for the code (both MXML and AS) it's excellent.
I don't know what difference it makes, but there seems to be a mismatch of method signatures. The <code>getBytes()</code> method called in your <code>doPost()</code> method has only one argument: byte[] bytes = StreamUtils.getBytes(stream); while the method source you included has two arguments: publi...
What's the best way to implement user controls in ASP.NET MVC?
|asp.net-mvc|user-controls|
Like many others on this site I am considering a move to ASP.NET MVC for future projects. Currently my sites are running the traditional ASP.NET 2.0 Web Forms, and it works Ok for us, so my other option is just to stick with what I know and make the move to ASP.NET 3.5 with the integrated AJAX stuff. I'm wondering ...
|asp.net-mvc|user-controls|partials|
|asp.net-mvc|user-controls|
DSL is just a fancy name and can meen different things: - Rails (the Ruby thing) is sometimes called a DSL because it adds special methods (and overwrites some builtin ones too) for talking about web applications - ANT, Makefile syntax etc. are also DSLs, but have their own syntax. This is what I would call a DSL...
As far as how to set up the DNS subdomain wildcard, that would be a function of your DNS hosting provider. This would be different steps depending on which hosting provider you have and would be a better question for them. Once you've set that up with the DNS host, from your web app you really are just URL rewriti...
Ensure that you're running your script AFTER the page has rendered. If your script is at the top of the page and runs right away, and your DIV is below that script the DIV doesn't exist yet.
Also note that using the "foreach" method in the original question does have some limitations, such as not being able to remove items from the list during the iteration. The new for-loop is easier to read and removes the need for a separate iterator, but is only really usable in read-only iteration passes.
I would highly recommend reading [Head First Design Patterns][1] from O'Reilly. This explains how these patterns can be used in the real world. ![alt text][2] I'd also add that don't try design too much with patterns in mind. More, look for "code smells" which a pattern might help solve. [1]: http://www.a...
The short answer: Java garbage collection is a very finely tuned tool. System.gc() is a sledge-hammer. Java's heap is divided into different generations, each of which is collected using a different strategy. If you attach a profiler to a healthy app, you'll see that it very rarely has to run the most expensive kind...
The short answer: Java garbage collection is a very finely tuned tool. System.gc() is a sledge-hammer. Java's heap is divided into different generations, each of which is collected using a different strategy. If you attach a profiler to a healthy app, you'll see that it very rarely has to run the most expensive kind...
I got to know one of the people (Jan) working on it a while ago (like 6 months) and have been playing with it ever since. I found the community around CouchDB to be both very knowledgable and helpful so that whenever I ran into an issue it was resolved in a matter of minutes or hours at least. We just kicked off a p...
What is the value of an anonymous unattached block in C#?
|c#|block|
In stumbled on this about a month ago. In C# you can make a block inside of a method that is not attached to any other statement. public void TestMethod() { { string x = "test"; string y = x; { int z = 42; ...
Well, Mysqldump is a series of SQL statements. You can do this with DTS, but why not just create a backup and restore it on your new machine? If you want to do it via SQL: http://msdn.microsoft.com/en-us/library/aa225964(SQL.80).aspx Or just right click the DB and hit Tasks -> Backup (http://msdn.microsoft.com/e...
Well, Mysqldump is a series of SQL statements. You can do this with DTS, but why not just create a backup and restore it on your new machine? If you want to do it via SQL: http://msdn.microsoft.com/en-us/library/aa225964(SQL.80).aspx Or just right click the DB and hit Tasks -> Backup (http://msdn.microsoft.com/e...
How to avoid garbage collection in real time C# application ?
|c#|garbage-collection|finance|real-time|
I'm writting a financial C# application which receive messages from the network, translate them into different object according to the message type and finaly apply the application business logic on them. The point is that after the business logic is applied, I'm very sure I will never need this instance again. Rath...
Are you sure you want to use the C library, even if it is that small? Once 64 bit gets a little more common, you'll need to start building/deploying both 32 bit and 64 bit versions of the library as well. And depending on what the C code is like, you may or may not need to update the code to make it build as 64 bit...
Yes, that should work. If it doesn't, then use 'ps' (or your platform's equivalent) to check whether those arguments are making it on the JVM's command line. Was that the question?
You may have problems running the image locally, you'll want to use VMWare converter to transfer the image in a format you can use (in VMWare server etc). Otherwise, use vifs in the remote cli: http://www.vmware.com/pdf/vi3_35/esx_3/r35u2/vi3_35_25_u2_rcli.pdf
Hmm. You can specify a VaryByCustom attribute on the OutputCache item. The value of this is passed as a parameter to the GetVaryByCustomString method that you can implement in global.asax. The value returned by this method is used as an index into the cached items - if you return the number of comments on the page, for...
Is there any wiki engine that supports page creation by email?
|email|wiki|mime|wiki-engine|
I want to consolidate all the loose information of the company I work for into a knowledge base. A wiki seems to be the way to go, but most of the relevant information is buried inside PST files, and it would take ages to convince people to manually translate their emails one by one (including attachments) into wiki pa...
FWIW, I did finally find solution to the situation. I had my travel buddy (who is still stuck in the qwerty stone age) type while I dictated. That was a 10x speed improvement over my hunting-and-pecking. And much easier, too.
Have you tried these tips? [http://weblogs.asp.net/haroonwaheed/archive/2008/06/30/ASP.NET-Performance-Tips.aspx][1] [1]: http://weblogs.asp.net/haroonwaheed/archive/2008/06/30/ASP.NET-Performance-Tips.aspx
Book: Database Design for Mere Mortals
I'd hop over to [http://www.w3.org/TR/wsdl.html][1] which I think explains Port, Service and Endpoint reasonably well. A locator is an implementation specific mechanism that some WS stacks use to provide access to service endpoints. [1]: http://www.w3.org/TR/wsdl.html
If you change "*" to just the parameters the cache should vary on (PostID?) you can do something like this: //add dependency string key = "post.aspx?id=" + PostID.ToString(); Cache[key] = new object(); Response.AddCacheItemDependency(key); and when someone adds a comment... Cache.Remove(...
In MS SQL Server Management Studio on the object explorer, right click on the database. In the context menu that follows select 'Tasks -> Take Offline'
"3" for those cases, I usually put in my scripts if(!arrayList[arrayList.length -1]) arrayList.pop(); You could make a utility function out of that.
I was intrigued so I looked it up in the definition of [ECMAScript 262 ed. 3](http://www.ecma-international.org/publications/standards/Ecma-262.htm) which is the basis of JavaScript 1.8. The relevant definition is found in section 11.1.4 and unfortunately is not very clear. The section explicitly states that elisions (...
You can use [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] so that it doesn't show up in Intellisence. If the consumer still want's to use it they can, but it won't be as discoverable. Keiths point about over engineering still stands though.
If you select only the columns you want in the linq query, and then call .ToList() on the query, it will be immedietly executed, and will only bring back the columns you are interested in. For example if you do this: var q = from p in dataContext.products select p.ProductName; var results = q.ToList(); Y...
It seems to me that the Firefox behavior is correct. What is the value of the 6th value in IE (sorry I don't have it handy to test). Since there is no actual value provided, I imagine it's filling it with something like 'null' which certainly doesn't seem to be what you intended to have happen when you created the ar...
You can use expect command to populate the username/password info
You could build your own Attribute derived class, say 'NonCallableAttribute' to qualify methods, and then add to your build/CI code analysis task the check to monitor if any code is using those methods. In my opinion, you really cannot force developers to not use the method, but you could detect when some broke the ...
Legacy systems (mentioned already) or interfacing outside vendor's systems might necessitate the 8 character cap. It could also be a misguided attempt to save the users from themselves. Limiting it in that fashion will result in too many pssw0rd1, pssw0rd2, etc. passwords in the system.
Porting existing code to a new environment may be one reason. Some of your business logic and domain functionality may exist in Python, and the group that writes that code insists on using Python. But the group that deploys and maintains it may want the managability of a J2EE cluster for the scale. You can wrap the ...
It's a pattern called Null Object [http://en.wikipedia.org/wiki/Null_Object_pattern][1] [1]: http://en.wikipedia.org/wiki/Null_Object_pattern