instruction
stringlengths
0
30k
Martin Fowler's **[Refactoring: Improving the Design of Existing Code][1]** has already been listed. But I will detail why it has impacted me. The essence of the whole book is about structuring code so that it is simpler to read and understand by *humans*. It teaches me strongly that the code that I write is meant f...
You may be able to do this through [self.establish_connection][1] [1]: http://blog.whitet.net/articles/2008/01/30/rails-has_many-with-models-over-different-databases
Why does HttpCacheability.Private suppress ETags?
|asp.net|caching|http|
While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object. My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using: cache...
While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object. My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCachea...
Forward declaring enums is non-standard, because pointers to different enum types are not guaranteed to be the same size. The compiler may need to see the definition to know what size pointers can be used with this type. In practice, at least on all the popular compilers, pointers to enums are a consistent size. For...
From using third party libraries on Windows I've learned the following two things: Try to distribute your library as a DLL rather than a static library. This gives way better compatibility between different c compilers and linkers. Another problem with static libraries in visual c++ is that the choice of runtime lib...
If you want to work with the same installation, you should seriously consider the Remote Desktop Server/Client solution, bundled into every windows OS from XP. Basically, this app displays the view from your remote desktop to your local one, using highly compressed images; this works even via low-bandwidth internet co...
Use the following attribute ... <pre><code> [Browsable(false)] public bool SampleProperty { get; set; } </code></pre>
Use the following attribute ... using System.ComponentModel; [Browsable(false)] public bool SampleProperty { get; set; } In VB.net, this [will be][1]: <System.ComponentModel.Browsable(False)> [1]: http://stackoverflow.com/questions/71440/set-a-usercontrol-property-to-not-show-up-in-v...
At work we give points for removing Withs from an existing Win 32 code base because of the extra effort needed to maintain code that uses them. I have found several bugs in a previous job where a local variable called BusinessComponent was masked by being within a With begin block for an object that a published propert...
Has anyone hooked up BizTalk and Fogbugz?
|fogbugz|biztalk|
We have an intranet system that schedules routine tasks. We also have Fogbugz for bug tracking. When an urgent bug comes in, we track that task in the bugtracker. However, I need to write back to both the Intranet and our CMS. I'm thinking Biztalk as the middle piece, but am not sure the best way to go about it. Databa...
The grey line is supposed to be there. The reason why it looks odd is because the very top is hidden by the buffer element. Remove the `background-color` rule from this ruleset: .buffer { float: left; width: 160px; height: 20px; margin: 0px; padding: 0px; background-color: rgb(255,255,255); }
Write down all the short-cuts and features that you use in your current editor while you're using it at work. Then sit down on Saturday morning and using Google and stack overflow find out how to do each one of those in vi. Probably best if you use a sheet (or sheets) of paper for this. Now disable/delete the other ...
I know you asked specifically about pentesting tools, but since those have been amply answered (I usually go with a mix of AppScan and trained pentester), I think it's important to point out that *pentesting is not the only way to "check for security loopholes", and is often **not the most effective**.* Source code...
First of all, you may want to pick up Vim; it has a vastly superior feature set along with everything vi has. That said, it takes discipline to learn. If you have a job and can't afford the productivity hit (without getting fired), I'd suggest taking on a weekend project for the sole purpose of learning the editor. ...
I think the general answer here is to use any language + http library + xml parser. I find that using ruby + hpricot gives a nice clean solution: require 'rubygems' require 'hpricot' require 'open-uri' sites = %w(http://www.google.com http://www.stackoverflow.com) sites.each do |site| ...
I think the general answer here is to use any language + http library + html/xpath parser. I find that using ruby + hpricot gives a nice clean solution: require 'rubygems' require 'hpricot' require 'open-uri' sites = %w(http://www.google.com http://www.stackoverflow.com) sites.each do |si...
As Espo hinted at, I'm pretty sure there's no direct way to do what you're asking. As he said, you can sort-of accomplish it by limiting the user's access to only procs that have built-in NOLOCK coded in them.
Ideally HTML tables should only be used for tabular data. However tables are also the simplest way to create some specific types of grid-based layouts, which are hard to emulate in cross-bowser compatible CSS. [This article][1] describes the issue in more details. The CSS spec does support grid-based layouts equival...
You could configure your support staff's SQL Management Studio to set the default transaction isolation level to READ UNCOMMITTED (Tools->Options->Query Execution->SQL Server->Advanced). This is functionally the same as having NOLOCK hints on everything. The downsides are that you'd have to do this for each member ...
[SharpDevelop][1] has a converter built-in IIRC. [1]: http://www.icsharpcode.net/OpenSource/SD/
The 3 main advantages of jQuery are: - its light weight when compared to other javascript frameworks - a wide range of [plugins][1] available for various specific needs - is easier for a designer to learn javascript as it uses familiar CSS syntax. jQuery is [Javascript for Designers][2] [1]: http://p...
In my experience you can't lower the color depth with the default vnc server. I won't assert it, because maybe that behaviour could be changed using a console command. I'd recommend installing another VNC server in mac, like http://sourceforge.net/projects/osxvnc/
How to do I check CPU and Memory Usage in Java?
|java|operating-system|cpu|ram|
I need to check CPU and memory usage for the server in java, anyone know how it could be done?
What I am about to suggest would still require a makefile, so I am partially repeating the advice above. Or, as was also mentioned earlier, maybe you already have a makefile, in which case you will have even fewer steps in order to accomplish what I am about to describe. Once you know what your machine-specific win...
I had a situation similar to this and this was the solution I resorted to: Select * FROM t1 INNER JOIN t2 ON t1.id = t2.id AND t1.country = t2.country AND t1.country = 'US' I noticed that my query ran faster in this scenario. I made the assumption that joining on the constant saved the engine time because th...
Most likely a corrupted project.res file. Try renaming the old and see if it is successfully recreated?
Because simple date format you specified discards the milliseconds. So the resulting Date object does not have that info. So when you print it out, its all 0s. On the other hand, the Date object does retain the milliseconds when you assign it a value with milliseconds (in this case, using new Date()). So when you pr...
@openid.aol.com/imnotsc that's not true. This will work: list(,,$thirdElement) = $myArray;
@Scott Reynen that's not true. This will work: list(,,$thirdElement) = $myArray;
Java (complete content of X.java): class X { public static void main(String[] args) { main(null); }} Considering all the syntactic sugar, I am wondering if any shorter can be done in Java. Anyone? **EDIT** Oops, I missed there is already almost identical solution posted.
Java (complete content of X.java): class X { public static void main(String[] args) { main(null); }} Considering all the syntactic sugar, I am wondering if any shorter can be done in Java. Anyone? **EDIT** Oops, I missed there is already almost identical solution posted. **EDIT 2** I wo...
Java (complete content of X.java): class X { public static void main(String[] args) { main(null); }} Considering all the syntactic sugar, I am wondering if any shorter can be done in Java. Anyone? **EDIT:** Oops, I missed there is already almost identical solution posted. **EDIT 2:** ...
Changing the annotation is a bad idea IMO. As it can't be changed to lazy at runtime. Better to make everything lazy, and fetch as needed. I'm not sure I understand your problem without mappings. Left join fetch should be all you need for the use case you describe. Of course you'll get back an order for every orderl...
We are using Subversion with TortoiseSVN and VisualSVN. Works very well. If you only want to work on an internal network you don't need VisualSVN. Just [install the Subversion server as a Windows Service][1]. Regarding the problem of keeping old revision history. It may make sense to keep the VSS database. Just ...
You can find a great document about time management in [Wouter van Oortmerssen][1] (aka Aardappel, the developer of famouses Open Source games like [cube][2] and http://sauerbraten.org/ ) The article I'm talking about is [this][3] [1]: http://strlen.com/ [2]: http://www.cubeengine.com/ [3]: http://strle...
No. You can extend previously declared classes, though, if that helps.
What would be wrong with doing something like the following: Defining a 'Maintainer' interface with the addListener(Listener, Enum) method. Create a DefaultMaintainer class (as above) which implements Maintainer. Then, in each Listener class, 'inject' the Maintainer interface (constructor injection might be a ...
Well you can make it ignore the error by doing an INSERT IGNORE which will just truncate the data and insert it anyway. (from http://dev.mysql.com/doc/refman/5.0/en/insert.html ) > If you use the IGNORE keyword, errors > that occur while executing the INSERT > statement are treated as warnings > instead. For exam...
When using Linq to SQL with stored procedures, must char(1) columns be returned as c# chars?
|c#|.net|visual-studio|linq-to-sql|
When using Linq to SQL and stored procedures, the class generated to describe the proc's result set uses char properties to represent char(1) columns in the SQL proc. I'd rather these be strings - is there any easy way to make this happen?
I would probably construct a query that gets the instance where Primary = true. I haven't used Win32_OperatingSystem in a while, but I seem to remember getting multiple instances, and the one that was currently booted had Primary equal to true.
The behaviour of the code is undefined. You may be lucky (or not) and it may work with your compiler, but really that's not correct code. There's two problems with it: 1. The delete should be a vector delete. 2. The delete should delete the same type as the new. So to be entirely correct, you want to be doing so...
Why is using a different parser such a problem? Bison is readily available, and (at least on linux) yacc is usually implemented as bison. You shouldn't need any changes to your grammar to use it (except for adding %destructor to solve your issue).
The FlashWindowEx Win32 API is the call used to do this. The documentation for it is at: http://msdn.microsoft.com/en-us/library/ms679347(VS.85).aspx
Well, I have written a couple of research papers in D as have others. http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.announce&artnum=13337 http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=9466.
You don't have to be a great designer to come out with a decent UI and a great user experience for your application. I think there are certain principles you can follow that can dramatically improve your application. At a high level this includes: - Identifying your top 3 use cases - Measuring and reduc...
|asp.net|http|caching|
|asp.net|http|caching|c#|
|c#|asp.net|http|caching|
|asp.net|http|caching|c#|
|c#|asp.net|http|caching|
|c#|asp.net|https|caching|
While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object. My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCachea...
While writing a custom IHttpHandler I came across a behavior that I didn't expect concerning the HttpCachePolicy object. My handler calculates and sets an entity-tag (using the SetETag method on the HttpCachePolicy associated with the current response object). If I set the cache-control to public using the SetCachea...
The Java API has [classes][1] for manipulating JAR files. [1]: http://java.sun.com/javase/6/docs/api/java/util/jar/package-summary.html
When you parse a date it only uses the information you provide. In this case it only knows MM-dd-yyyy HH:mm. Creating a new date object returns the current system date/time (number of milliseconds since the epoch).
You can use Java's ZipFile and ZipEntry classes to read the contents of a JAR file, then use ZipOutputStream to create a new one.
Tools to effectively manage the information?
|information-management|
How do you guys manage the information overflow? What are the tools that you guys use? One of the usefull tool is RSS feed reader. Does Any body uses any other tools or any other ways to effectively manage the information?
How do I store the window size between sessions in Qt?
|qt|size|window|restore|
I have a QMainWindow in a Qt application. When I close it I want it to store its current restore size (the size of the window when it is not maximized). This works well when I close the window in restore mode (that is, not maximized). But if I close the window if it is maximized, then next time i start the application ...
umm, the is more of a physcology question than a programming question, but the best way I have been able to do things that I really didn't want to do is to just do it, and stop trying to thing of ways to motivate myself to do it. Just think of it as brushing your teeth. Do you have to motivate yourself to do it? N...
toString() of a Date object does not show you the milliseconds... But they are there So new Date() is an object with milisecond resolution, as can be seen by: System.out.printf( "ms = %d\n", myDate.getTime() % 1000 ) ; However, when you construct your date with SimpleDateFormat, no milliseconds are pass...
There's a -f option to umount that you can try: umount -f /mnt/fileshare Are you specifying the '-t cifs' option to mount? Also make sure you're not specifying the 'hard' option to mount. You may also want to consider [fusesmb][1], since the filesystem will be running in userspace you can kill it just lik...
On Windows Mobile device, what is the best way to display an OK button instead of the X button?
|c++|windows-mobile|
I have a C++ program that when run, by default, displays the X in the upper right corner. Clicking X, minimizes the program. I've added code using the SHInitDialog function to change the X to OK, so that clicking OK exits the program. My question: Is there a better method that applies to the window, since SHInitDial...
Could your version control tell you this? For example in Subversion "Check for modifications" will list everything changed since your last checkin (although not since your last build) Mind you, doesn't "build" automatically do exactly that? (build only what's changed)?
You can use WinDBG and trap all first-chance exceptions. I'm sure you'll see something interesting. If so, you can use SOS to clean up the stack and post it here to help us along. Or you can use Visual Studio by enabling the trap of all exceptions. Go to "Debug" and then "Exceptions" and make sure you trap everythin...
I've used [this LGPL-licensed feedcreator class][1] in the past and it worked quite well for the very simple use I had for it. [1]: http://www.bitfolge.de/rsscreator-en.html
PHP5 now comes with the SimpleXML extension, it's a pretty quick way to build valid XML if your needs aren't complicated. However, the problem you're suggesting doesn't seem to an issue of implementation more a problem of syntax. Perhaps you could update your question with a code example, or, a copy of the XML that ...
I personally have found that SP's tend to be faster performance wise, at least for the large data items that I execute on a regular basis. But I know many people that swear by OR tools and wouldn't do ANYTHING else.
You can certainly edit the web.config file for your sites. The one thing that you should be aware of, however, is that when you start editing files manually on the file system, you will have to remember to manually make those changes across all servers in the farm (assuming a farm exists). In addition to this, when y...
If you're using PHP, the [SimplePie][1] library will do this. [Here's a tutorial][2]. [1]: http://simplepie.org/ [2]: http://www.webmaster-source.com/2007/08/06/merging-rss-feeds-with-simplepie/
To list the tables you can also do: SELECT name FROM sqlite_master WHERE type='table';
Just try to use common sense. Also some say - and I have to agree with them - that, if you're finding yourself joining 6 (the magic number) tables together in most of your queries - not including reporting related ones- , than you might consider denormalizing a bit.
I'd express the format as: "1-3 dot-separated components, each numeric except that the last one may be *" As a regexp, that's: ^(\d+\.)?(\d+\.)?(\\*|\d+)$ I'm a bit rusty, so I'm not sure about the operator precedence in that last bracket. I think it's right, but you might need (\\*|(\d+)).
The 3 main advantages of jQuery are: - its light weight when compared to other javascript frameworks - it has a wide range of [plugins][1] available for various specific needs - it is easier for a designer to learn javascript as it uses familiar CSS syntax. jQuery is [Javascript for Designers][2] [1]...
The [Pyglet][1] library for Python might suit your needs. It lets you use OpenGL, a cross-platform graphics API. You can disable anti-aliasing and capture regions of the screen to a buffer or a file. In addition, you can use its event handling, resource loading, and image manipulation systems. You can probably also tie...
Q: "Is there any way to locate all the INDIRECT formulas that currently refer to the tables we want to move?" As I read it, you want to look inside the arguments of INDIRECT for references to areas of interest. OTTOMH I'd write VBA to use a regular expression parser, or even a simple INSTR to find INDIRECT( read f...
Yes, it's safe. A pretty common pattern is to create an object, then add it to a queue or some other collection. A second "consumer" thread takes items from the queue and does something with them. Here, you'd need to synchronize the queue but not the objects that are added to the queue. It's NOT a good idea to ju...
Without any specifics about the kinds of performance issues you're seeing, I can only offer a generalization: In my experience, most database query performance issues arise from lack of proper indices. So my suggestion for a first action would be to check your query plans for non-indexed queries.
[ "A very clear article on how to make a web service more RESTful using delicious"][1] [1]: http://www.peej.co.uk/articles/restfully-delicious.html
Try Jquery Interface Elements here - http://interface.eyecon.ro/docs/carousel Here's a sample. http://interface.eyecon.ro/demos/carousel.html I looked around for a Jquery image carousel a few months ago and didn't find a good one so I gave up. This one was the best I could find.
There are a class of problems where building the result in a collection structure on the database side is much preferable to returning the result's parts to the client, roundtripping for each part. For example: arbitrary depth recursive relationships (boss of) There's another class of query problems where the da...
HWND hHandle = FindWindow(NULL,"YourApplicationName);<br> FLASHWINFO pf;<br> pf.cbSize = sizeof(FLASHWINFO);<br> pf.hwnd = hHandle;<br> pf.dwFlags = FLASHW_TIMER|FLASHW_TRAY;(or FLASHW_ALL to flash and if it is not minimized)<br> pf.uCount = 8;<br> pf.dwTimeout = 75;<br> <br> FlashWindowE...
[SetForegroundWindow](http://msdn.microsoft.com/en-us/library/ms633539.aspx) Skizz
Best way to initiate a download?
|download|php|javascript|
On a PHP-based web site, I want to send users a download package after they have filled out a short form. The site-initiated download should be similar to sites like download.com, which say "your download will begin in a moment." A couple of possible approaches I know about, and browser compatibility (based on a qui...