instruction
stringlengths
0
30k
Let's say you work someplace where every change to source code must be associated with a bug-report or feature-request, and there is no way to get that policy reformed. In such an environment, what is the best way to deal with code refactorings (that is, changes that improve the code but do not fix a bug or add a feat...
I don't understand the question -- you're extending System.Exception, and you already added the Elmah field. That's where it belongs -- as a public property of the exception itself.
I often use it for guarding memory usage, things that need to be freed that were returned from the OS. For example: DATA_BLOB blobIn, blobOut; blobIn.pbData=const_cast<BYTE*>(data); blobIn.cbData=length; CryptUnprotectData(&blobIn, NULL, NULL, NULL, NULL, CRYPTPROTECT_UI_FORBIDDEN, &blobOut...
for i in `ls $1/resources`; do if [ $i != "database.db" ] && [ $i != "tiles" ] && [ $i != "map.pdf" ] && [ $i != "map.png" ]; then svn export -q $1/resources/$i ../MyProject/Resources/$i
Made this in Java. The regex was borrowed from [this forum][1]. final String regex = "[\\s](\\({0,1}\\d{3}\\){0,1}" + "[- \\.]\\d{3}[- \\.]\\d{4})|" + "(\\+\\d{2}-\\d{2,4}-\\d{3,4}-\\d{3,4})"; final Pattern phonePattern = Pattern.compile(regex); /* The result set */ Set<File> files = new Has...
Unhandled exceptions filter in a windows service
|.net|windows-service|exception|
I am creating a windows service and want to know best practices for this. In all my windows Program I have a form that asks the user if he wants to report the error and if he answers yes I created a case in FogBugz. What should I do in a windows service.
|.net|exception|windows-services|
I have used barcode fonts successfully with SSRS and PDF. You must have the font installed on both the server (for rendering and viewing from the browser), as well as from the client. When using barcode fonts, there's not really a best "match" for postscript so the PDF does not have a valid barcode font embedded wi...
You shouldn't fill `.Message` with debug information, but rather with a concise, helpful piece of text. [http://msdn.microsoft.com/en-us/library/system.exception.message.aspx][1] >**The text of Message should completely describe the error and should, when possible, explain how to correct it.** The value of the Me...
|python|windows|linux|macos|diskspace|
I need a way to determine the space remaining on a disk volume using python on linux, Windows and OS X. I'm currently parsing the output of the various system calls (df, dir) to accomplish this - is there a better way?
I have spent 4 months on a project working extremely closely with a designer and he has still not picked up the basic idea of CVS (which is not my choice of source control system). I'm talking template files, JavaScript and CSS here. He's not stupid, it's just one of these things that makes his job harder so he resists...
How does off-the-shelf software fit in with agile development?
|agile|off-the-shelf-software|
Maybe my understanding of agile development isn't as good as it should be, but I'm curious how an agile developer would potentially use off-the-shelf (OTS) software when the requirements and knowledge of what the final system should be are changing as rapidly as I understand them to (often after each iteration of devel...
|refactoring|bug-tracking|
Lets have a look at each option: - Write up a bug-report and associate the refactoring with it. If you feel that, in your opinion, the original code poses a security risk or potential for crashing or instability. Write a small bug report outlining the danger, and then fix it. - Write up a feature-request a...
I agree with many and especially [Jason](http://stackoverflow.com/questions/54188/are-c-reads-and-writes-of-an-int-atomic#54224). On windows, one would likely use InterlockedAdd and its friends.
In [Chapter 10. Quantity archetype pattern](http://safari.oreilly.com/032111230X/part03#X2ludGVybmFsX1RvYz94bWxpZD0wMzIxMTEyMzBYL2NoMTA=) of the book [Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML](http://www.informit.com/store/product.aspx?isbn=9780321112309&aid=3B419801-6640-4A...
Whatever you do, don't use a static UriBuilder. This introduces all sorts of potential race conditions that you might not detect until you are under heavy load. If two different threads called UriHelper.NormalizeRelativePath at the same time, the return value for one could be passed back to the other caller arbit...
I usually use [SQLAlchemy][1]. It's pretty powerful and is probably the most mature python ORM. If you're planning on using CherryPy, you might also look into [dejavu][2] as it's by Robert Brewer (the guy that is the current CherryPy project leader). I personally haven't used it, but I do know some people that lov...
java.util.Properties is based on Hashtable, which does not store its values in alphabetical order, but in order of the hash of each item, that is why you are seeing the behaviour you are.
We use RNDIS at work. and I've found that it blue screens my machine every now and again (about every month or two). However others (at my work) have not had this happen, so it could just be the particular device that I use. I think it is stable enough for development, so give it a go.
I do it the same way as Gulzar, just keep trying with a loop. In fact I don't even bother with the file system watcher. Polling a network drive for new files once a minute is cheap.
Wow. This is so dependent on the device, connection method, connection type, ISP throttling, etc. involved in the end-to-end link. To try and work out an average speed would be fairly impossible. Think, fat pipe at home (8Gb plus) versus bad wireless connection provided for free at the airport (9.6kb) and you ...
Can't you adjust the RewriteCond to only operate on example.com? RewriteCond %{HTTP:Host} ^example\.com(.*) [NC]
It's not a bad idea. Sometimes I find myself stumbled upon some file trying to figure out where it comes from :) But how are you going to track item's sources? Content can be obtained by various means - web browser, download manager, simply by copying from network share.
We want to keep our package configs in a database table, we know it gets backuped with our other data and we know where to find it. Just a preference. I have found that to get this to work I can use an environment variable configuration to set the connection string of the connection manager that I am reading my pack...
My approach has been to use third party code for some core functionality. For example, I use Subsonic for my data access, Devexpress components for UI and Peter Blum Data Entry Suite for data entry and validation. Subsonic is open source, Devexpress Peter Blum's controls have source code available for an extra fee. It...
Maybe my understanding of agile development isn't as good as it should be, but I'm curious how an agile developer would potentially use off-the-shelf (OTS) software when the requirements and knowledge of what the final system should be are changing as rapidly as I understand them to (often after each iteration of devel...
Depends on what you want for performance. The case statement is ugly but does not consume memory that would need to be allocated. However, you could create a class for your fields and load instances of them into a Dictionary. Perform this operation in the global.asp script so it only happens once. Store the dict...
Is there anything wrong with o.getClass().equals(T.class) if accepting subclasses is ok you can use something like o instanceof T.class
Is there anything wrong with o.getClass().equals(T.class) if accepting subclasses is ok you can use something like o instanceof T.class To answer myself: yes there is. I could only make it working like this: public class Test<E> { private E e; public void s...
I could only make it working like this: public class Test<E> { private E e; public void setE(E e) { this.e = e; } public boolean sameClassAs(Object o) { return (o.getClass().equals(e.getClass())); } ...
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult -- the ...
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult -- the only s...
To draw a centered text: TextRenderer.DrawText(g, "my text", Font, Bounds, ForeColor, BackColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.GlyphOverhangPadding); Determining optimal font size to fill an area is a bit more difficult. One working ...
I used the following code is an example of how I captured SOAP requests in a application written a while back. <System.Diagnostics.Conditional("DEBUG")> _ Private Sub CheckHTTPRequest(ByVal functionName As String) Dim e As New UTF8Encoding() Dim bytes As Long = Me.Context...
java.util.Properties is a subclass of java.util.**Hashtable**. ('Hash', being the key here.)You'd have to come up with your own customer implementation based on something that keeps/defines order...like a TreeMap.
From a physical and logical architecture standpoint, nothing beats the whiteboard, drawing up the layers/tiers of the application in boxes. Then create an electronic copy using Visio. After that, iteratively dive into each layer and design it using appropriate tools and techniques. Here are what I commonly use: ...
If you find that the time needed to fully implement OO in your project is needlessly causing missed deadlines, then yes. There has to be a trade off between releasing software and full OO fidelity. How to decide depends on the person, the team, the project and the organization running the project.
Yes, of course there is :-) object oriented techniques are a tool ... if you use the wrong tool for a given job, you will be over complicating things (think spoon when all you need is a knife). To me, I judge "how much" by the size and scope of the project. If it is a small project, sometimes it does add too much c...
Glade is very useful for creating interfaces, it means you can easily change the GUI without doing much coding. You'll find that if you want to do anything useful (e.g. build a treeview) you will have to get familiar with various parts of the GTK documentation - in practice finding a good tutorial/examples.
Yes, it's definitely possible -- common, either. I once worked with a guy who created a data structure to bind to a dropdown list -- so he could allow users to select a gender. True, that would be useful if the list of possible genders were to change, but they haven't as yet (we don't live in California)
My advice is not to overthink it. That usually results in over or under doing SOMETHING (if not OO). The rule of thumb that I usually use is this: if it makes the problem easier to wrap my head around, I use an object. If another paradigm makes it easier to wrap my head around than it would be if I used an object, ...
Even shorter: for i in `ls $1/resources`; do if [ $i != databse.db -a $i != titles -a $i != map.pdf ]; then svn export -q $1/resources/$i ../MyProject/Resources/$i fi done; The `-a` in the if expression is the equivalent of the boolean AND in shell-tests. For more see `man test`
JBoss wraps up all DataSources with it's own ones. That lets it play tricks with autocommit to get the specified J2EE behaviour out of a JDBC connection. They are _mostly_ serailizable. But you needn't trust them. I'd look carefully at it's wrappers. I've written a surrogate for JBoss's J2EE wrappers wrapper for...
I have discovered another caveat (which in my case was what was "wrong") It appears that the unit with the HelpInsight comments **must** be explicitly added to the project. It is not sufficient to simply have the unit in a path that is searched when compiling the project. In other words, the unit must be include...
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider th...
Not a strict answer per se, but I think that using off the shelf software as a component in a software solution can be very beneficial if: - It's data is open, e.g. an open database or a web service to interact with it - The off the shelf system can customised *easily* using a similar programming paradigm to th...
Be aware that [Microsoft do not recommend that you static link the runtime into your project][1], as this prevents it from being serviced by windows update to fix critical security bugs. There are also potential problems if you are passing memory between your main .exe and .dll files as if each of these static links th...
Although generally a UML tool, I would look at [StarUML][1]. It supports [additional modules beyond what are already built in][2]. If it doesn't have what you need built in or as a module, I supposed you could make your own, but I don't know how difficult that is. [1]: http://staruml.sourceforge.net/en/ [2]: ...
I don't think that your results are all that surprising -- if anything it is that Postgres is so fast. Does the Postgres query run faster a second time once it has had a chance to cache the data? To be a little fairer your test for Java and Python should cover the cost of acquiring the data in the first place (idea...
Quite frankly you should tell the designer that images can, should and "will be put in source control mister!" :) It may be slightly non-conventional and you wont be able to do a merge or anything of that nature, but there will be revisions and a history, etc .. Images can also be embedded in a resource file which...
using System.IO; DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { if (d.IsReady && d.DriveType == DriveType.Removable) { // This is the drive you want... } } The DriveInfo class documentation is here: http://msdn.micros...
.NET Interfaces
|.net|user-controls|interface|
Over the past few years I've changed from having a long flowing page of controls that I hid/showed to using a lot of user controls. I've always had a bit of a discussion between co-workers on best practices. Should you have properties that you populate, or use paramterized sub's to load the information in your cont...
@jj33, you're absolutely right, on both counts. #include <stdio.h> int main(int argc, char *argv[]) { char *s = "Hello, World"; char *s2 = "he"; printf("4s: '%4s'\n", s); printf(".4s: '%.4s'\n", s); printf("4s2: '%4s'\n", s2); printf(".4s2: '%.4s'\n"...
If you understand the process of retain/release then there are two golden rules that are "duh" obvious to established Cocoa programmers, but unfortunately are rarely spelled out this clearly for newcomers. **1) If a function which returns an object has 'alloc', 'create' or 'copy' in its name then the object is yours...
To echo what Lance said - the SubSonic query language has a fluent interface which isn't as pretty as LINQ, but gives you some of the benefits (compile time checking, intellisense, etc.).
I'm not sure if interfaces are going to help you a lot here. My understanding is that you are breaking a page down into set of "composite" user controls that contain other controls, and you want to decide whether to use properties for setting values. I guess this really depends on how the user controls are designed...
Also keep in mind the **[SC.exe util][1]** which does not require visual studio to be installed. You can simply copy this exe to the server you want to create the service or even **run it remotely**. Use the **obj** parameter to specify a user. Apparently there is a GUI for this tool, but I have not used it. ...
I guess it is possible, but its hard to answer your in abstract terms (no pun intended). Give an example of over OO.
What the certificate validation is doing is validating all certificates in the chain. In order to truely do that it just contact the root store of each of those cerficates. If that's not something you want to happen you can deploy your own root store locally.
This one isnt really a book for the beginning programmer, but if you're looking for SOA design books, then [SOA in Practice: The Art of Distributed System Design][1] is for you. ![alt text][2] [1]: http://www.amazon.com/SOA-Practice-Distributed-System-Design/dp/0596529554/ref=pd_bbs_sr_3?ie=UTF8&s=books&qid...
Yes. See the concept of the "[golden hammer][1] [antipattern][2]" [1]: http://en.wikipedia.org/wiki/Golden_hammer [2]: http://sourcemaking.com/antipatterns/golden-hammer
Even if you are familiar with the internals, you should still load test your assumptions. I like to use the [PEAR Benchmark][1] package to compare different code. If you can isolate your code, you can keep your load testing simple. A typical technique is to run each option some number of times and see which one is f...
If you're working on a block of code, in most cases that's because there's either a bug fix or new feature that requires that block of code to change, and the refactoring is either prior to the change in order to make it easier, or after the change to tidy up the result. In either case, you can associate the refactorin...
Is this a webapp? Place your SoapExtension code in a HTTPModule, and inject the SOAP envelope into the HTTPOutput stream. That way, when in debug mode, I picture something like a collapsible div on the top of the page that lists all SOAP communication for that page.
I've found it easier to pool and reuse XMLHTTPRequest objects instead of creating new ones...
I think there are times when OO design can be taken to an extreme and even in very large projects make the code less readable and maintainable. For instance, there can be use in a footware base class, and child classes of sneaker, dress shoe, etc. But I have read/reviewed people's code where it seemed as though they we...
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider th...
Not a direct answer to your question, which Jonas has answered well, however this may be of assistance if you are worried about equality testing in hashes From our tests, depending on what you are requiring with hashcodes, in C#, hashcodes do not need to be unique for Equality operations. As an example, consider th...
I think I read somewhere that if during an iteration you discover that you have more than 20% more work that you initially thought then you should abandon the sprint and start planning a new one taking into account the additional work. So this would mean replanning with the business to see if they still want to go a...
I Don't know of any cross-platform way to achieve this, but maybe a good workaround for you would be to write a wrapper class that checks the operating system and uses the best method for each. For Windows, there's the [GetDiskFreeSpaceEx][1] method in the win32 extensions. [1]: http://aspn.activestate.com/AS...
in c# you can get the same by using the System.IO.DriveInfo class using System.IO; public static class GetDrives { public static IEnumerable<DriveInfo> GetCDDVDAndRemovableDevices() { return DriveInfo.GetDrives(). Where(d => d.DriveType == DriveType.Rem...
there is a Number.localeFormat function but I'm not sure it's what your after [http://msdn.microsoft.com/en-gb/library/bb310813.aspx][1] [1]: http://msdn.microsoft.com/en-gb/library/bb310813.aspx
The [os.statvfs()](http://python.org/doc/2.5/lib/os-file-dir.html) function is a better way to get that information for Unix-like platforms (including OS X). The Python documentation says "Availability: Unix" but it's worth checking whether it works on Windows too in your build of Python (ie. the docs might not be up t...
The [os.statvfs()](http://python.org/doc/2.5/lib/os-file-dir.html) function is a better way to get that information for Unix-like platforms (including OS X). The Python documentation says "Availability: Unix" but it's worth checking whether it works on Windows too in your build of Python (ie. the docs might not be up t...
In Oracle you can also use the EXISTS statement, which in some cases is faster. For example... SELECT name, number FROM cust WHERE cust IN ( SELECT cust_id FROM big_table ) AND entered > SYSDATE -1 would be slow. but SELECT name, number FROM cust **c** WHERE EXISTS ( SELECT cust_id FROM big_table ...
one way you could do it is to declare an interface say IGisObject that has the common properties declared on the interface. Then implement a concrete class which maps to each table. That way they'll still be all of type IGisObject.
Average User Download Speeds
|internet|download|performance|average|
Any ideas what the average user's download speed is? I'm working on a site that streams video and am trying to figure out what an average download speed as to determine quality. I know i might be comparing apples with oranges but I'm just looking for something to get a basis for where to start.
|internet|download|performance|average|
|internet|download|performance|average|
Looking for ASP.NET code to render a form that displays a view of an object
|asp.net|propertygrid|control|
I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox or a dropdownlist ...
|asp.net|control|propertygrid|
I've got the task of displaying a web form to represent the properties in a .NET class. In WinForms, there's a pre-fab control named PropertyGrid that is a lot like what I need. I'm just looking for something to display a simple layout of property names next to an appropriate control like a textbox for strings or a d...
|asp.net|controls|propertygrid|
How should I monitor potential threats to my site?
|monitor|alert|
By looking at our DB's error log, we found that there was a constant stream of almost successful SQL injection attacks. Some quick coding avoided that, but how could I have setup a monitor for both the DB and Web server (including POST requests) to check for this? By this I mean if there are off the shelf tools for sc...
|monitor|alert|
How to provide namespaces in JavaScript with instanced objects