instruction
stringlengths
0
30k
We have an intranet site backed by SVN, such that the site is a checkout out copy of the repository (working folder used only by IIS). Something on the site has been causing problems today, and I want to know how to find out what was checked out to that working folder in the last 48 hours. **Update:** If there's an...
Running this in a command window will stop it until the next reboot. sc stop wuauserv
Random weighted choice
|c#|algorithm|random|
Consider the class below that represents a Broker: public class Broker { public string Name = string.Empty; public int Weight = 0; public Broker(string n, int w) { this.Name = n; this.Weight = w; } } I'd like to randomly sele...
I agree with everyone else that you should try as hard as you can to separate the HTML/XHTML markup from the application logic. However, sometimes you do need to generate HTML/XHTML in the application logic for various reasons. In these cases what I have been trying to do is to ensure the bare minimum amount of pre...
Saple code for using IBM's PCOMM in C# o write an as400 screenscraper
|ibm-midrange|c#|com|interop|
Has anybody used C# to write a sample screen scraper for IBM as400?
Sample code for using IBM's PCOMM in C# o write an as400 screenscraper
|c#|com|interop|ibm-midrange|
In Python, indentation is a semantic element as well as providing visual grouping for readability. Both space and tab can indicate indentation. This is unfortunate, because: - The interpretation(s) of a tab varies among editors and IDEs and is often configurable (and often configured). ...
Yup, that was it... DirectoryInfo dirInfo = new DirectoryInfo(newDirectoryParent + newDirectoryName); if (dirInfo.Exists) { dirInfo.Delete(true); item.DTE.ExecuteCommand("View.Refresh", string.Empty); } ProjectItem folder = item.ProjectItem.Collection.AddFolder...
Where you can, use pre-increment instead of post-increment.
parsings strings: extracting words and phrases [JavaScript]
|javascript|regex|parsing|
I need to support exact phrases (enclosed in quotes) in an otherwise space-separated list of terms. Thus splitting the respective string by the space-character is not sufficient anymore. Example: input : 'foo bar "lorem ipsum" baz' output: ['foo', 'bar', 'lorem ipsum', 'baz'] I wonder whether this co...
du -a | sort -n | tail -99 to find the big files (or directories of files) to clean up to free up disk space.
Template metaprogramming and expression templates are becoming more popular in the scientific community as optimization methods that offload some of the computational effort onto the compiler while maintaining some abstraction. The resulting code is larger and less readable, but I have used these techniques to speed u...
You might want to have a look at [Process Lasso][1]. [1]: http://www.bitsum.com/prolasso.php
Given A -> B -> C -> D and a pointer to, say, item B, you would delete it by 1. free any memory belonging to members of B 2. copy the contents of C into B (this includes its "next" pointer) 3. delete the entire item C Of course, you'll have to be careful about edge cases, such as working on lists o...
Using /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app you can use the built-in accessibility system to look at properties of the UI element under the mouse. Take special note of the cmd-F7 action to lock focus on an element and the Refresh button. Sadly the element and property names...
If you do go the plugin route, do check out [Rails-Engines][1], which are intended to extend plugin semantics to Controllers and Views in a clear way. [1]: http://rails-engines.org/
There are 3 major ways of dealing with XML, in general: dom, sax, and xpath. The dom model is good if you can afford to load your entire xml file into memory at once, and you don't mind dealing with data structures, and you are looking at much/most of the model. The sax model is great if you only care about a few tags,...
Recently I was talking to a co-worker about C++ and lamented that there was no way to take a string with the name of a class field and extract the field with that name; in other words, it lacks reflection. He gave me a baffled look and asked when anyone would ever need to do such a thing. Off the top of my head I d...
One of the primary reasons to implement an application as a web application is that you get automatic upgrades for free. Why would users be getting prompted for upgrades on a web app? For Windows applications, the "update is available, do you want to upgrade?" functionality is provided by Microsoft using ClickOnce,...
Well, it really depends on your business model but for a lot of applications the SaaS model can end up biting you. It's great for a lot of things but for some larger applications the users are not investing as significant amount up front and could possibly move to something else before you've made any money. See ...
If you're providing a hosted solution, I wouldn't bother. Let the upgrade happen silently (perhaps with a notice that you did it). If you're selling an application that's hosted on their servers, let the upgrade decision be made by a single owner, not every user of the app.
Siebel gives an extensive rundown (for simple cases anyway) of possible sources of leaks, and there aren't any of those here. Both <code>value</code> and <code>factor</code> are evaluated only once and in order, and <code>rem</code> doesn't have any side effects. This is not good Lisp though, because there's no reas...
Your macro looks fine to me. I don't know what a leaky macro is, but yours is pretty straightforward and doesn't require any gensyms. As far as if this is "good" Lisp, my rule of thumb is to use a macro only when a function won't do, and in this case a function can be used in place of your macro. However, if this solut...
Best way to write a Safari Extension
|safari|apple|plugin-development|
What is the best way to write a Safari extension? I've written a couple XUL extensions for Firefox, and now I'd like to write versions of them for Safari. Is there a way that would allow you to add buttons or forms to the browser UI, since this is not possible with an Input manager or Service menu?
Sometimes by the time you "complete functionality" using copy and paste code, you've come to a point that it is maimed and mangled enough that any attempt at refactoring will actually take much, much longer than refactoring it at the point where it was obvious. In my personal experience my favorite "way of removing ...
I use Windsor from the [CastleProject][1] and have found it immensely useful in reducing dependencies. I haven't noticed a performance issue yet but one thing I do find is that the configuration can get a bit cumbersome. To help in this regard I'm starting to look at Binsor, which is a DSL for Windsor written in boo. ...
I use Windsor from the [CastleProject][1] and have found it immensely useful in reducing dependencies. I haven't noticed a performance issue yet but one thing I do find is that the configuration can get a bit cumbersome. To help in this regard I'm starting to look at Binsor, which is a DSL for Windsor written in boo. ...
Your best bet IMO would be to use javascript to look for a cookie named "origReferrer" or something like that and if that cookie doesn't exist you should create one (with an expiry of ~24hours) and fill it with the current referrer. That way you'll have preserved the original referrer all the way from your users fir...
Your best bet IMO would be to use javascript to look for a cookie named "origReferrer" or something like that and if that cookie doesn't exist you should create one (with an expiry of ~24hours) and fill it with the current referrer. That way you'll have preserved the original referrer all the way from your users fir...
A couple of things lead to me to question if it was true. One was the app that I use to author the installer, [InstallAware][1], only pulls in the .NET 2.0 Framework if I add the Report Viewer 2008 runtime. The other thing was what I had already mentioned in my question, that is we are testing our app without 3.5...
So far testing with or with out the .NET Framework works as expected. My installer has the user install version 2.0 of the Framework and everything works as expected. My concern is that 3.5 is listed as a prerequisite on the Report Viewer download page.
How do I log uncaught exceptions in PHP?
|php|exception|error-handling|error-logging|
I've found out how to convert errors into exceptions, and I display them nicely if they aren't caught, but I don't know how to log them in a useful way. Simply writing them to a file won't be useful, will it? And would you risk accessing a database, when you don't know what caused the exception yet?
What about backup and restore? Could you experience a customer wanting to restore a backup for one of their entities?
I'm all for XHTML Strict every time. I strongly believe that HTML should be more like XML. It's not hard to validate it if you know XML and the W3's validator ipoints you on the right track anyway. XHTML 2.0 is heading toward what the W3 have been aiming for for a long time - the semantic web. The best benefit of XH...
I think you'll have to combine a couple of these answers to get what you want. If you use nohup in conjunction with the semicolon, and wrap the whole thing in quotes, then you get: ssh user@target "cd /some/directory; nohup myprogram > foo.out 2> foo.err < /dev/null" which seems to work for me. With nohup, yo...
how to convert from prtime to .net datetime
|datetime|firefox.|
I want to convert a number that is in [PRTime][1] format (a 64-bit integer representing the number of microseconds since midnight (00:00:00) 1 January 1970 Coordinated Universal Time (UTC)) to a datetime. note that this is slightly different than the usual "number of millisecconds since 1/1/1970" [1]: http://...
|.net|firefox|datetime|
There's a good overview here (this marshaling support added for VS2008): http://www.codeproject.com/KB/mcpp/OrcasMarshalAs.aspx
Best way to get a list of differences between 2 of the same objects
|c#|oop|
I would like to generate a list of differences between 2 instances of the the same object. Object in question: public class Step { [DataMember] public StepInstanceInfo InstanceInfo { get; set; } [DataMember] public Collection<string> AdHocRules { get; set; } ...
If you are not opposed to using .NET the <a href="http://msdn.microsoft.com/en-us/library/system.io.filesystemwatcher.aspx">FileSystemWatcher</a> class will handle this for you fairly easily.
You can do this with a custom RMI Socket Factory. The socket factories create the sockets for RMI to use at both the client and server end so if you write your own you've got full control over the ports used. The client factories are created on the server, Serialized and then sent down to the client which is pret...
I've recently started to program in Python, so I've not really had chance to find out best practice yet. But, I've written a module that goes and finds all the tests and runs them. So, I have: <pre> app/ appfile.py test/ appfileTest.py </pre> I'll have to see how it goes as I progress to larger projects.
What are the pros and cons of object databases?
|database|
There is a lot of information out there on object-relational mappers and how to best avoid impedance mismatch, all of which seem to be moot points if one were to use an object database. My question is why isn't this used more frequently? Is it because of performance reasons or because object databases cause your data...
|database|oop|rdbms|relational|object-oriented-database|
Testing network interrupts in software
|c++|windows|testing|networking|network-programming|
I have a network C++ program in Windows that I'd like to test for network disconnects at various times. What are my options? Currently I am: 1. Actually disconnecting the network wire from the back of my computer 2. using ipconfig /release 3. Using the [cports][1] program to close out the socket completely ...
- **Familiarity.** The administrators of databases know relational concepts; object ones, not so much. - **Performance.** Relational databases have been proven to scale far better. - **Maturity.** SQL is a powerful, long-developed language. - **Vendor support.** You can pick between many more first-party (SQL server...
Cons: - Cannot be used by programs that don't also use the same framework for accessing the data store, making it more difficult to use across the enterprise. - Less resources available online for non SQL-based database - No compatibility across database ...
At [my company][1] we have enterprise installations ranging into the thousands of seats. If we implemented an auto-upgrade, our customers would mutiny! Large installations have peculiar issues that don't apply to small ones. For example, with 2000 users (not all of whom are, let us say, the most sophisticated of t...
Autoupdating .net applications
|.net|winforms|updating|
I've written 2 reasonably large scale apps in .net so far, and both of them have needed an updating facility to automatically update the application when I roll out new code. I've found the 'Enterprise application block updater' a bit too complex for my needs, and I've found 'click once' frustrating when it comes to...
There are lot's of times you want to dynamically instantiate and work with objects where the type isn't known until runtime. For example with OR-mappers or in a plugin architecture. Mocking frameworks use it, if you want to write a logging-library and dynamically want to examine type and properties of exceptions. If...
Writing dispatchers. Twisted uses python's reflective capabilities to dispatch XML-RPC and SOAP calls. RMI uses Java's reflection api for dispatch. Command line parsing. Building up a config object based on the command line parameters that are passed in. When writing unit tests, it can be helpful to use reflectio...
Bazaar. See [Bazaar in five minutes][1] for a great start. Whenever you save a file, run the `$ bzr commit -m "Added first line of text"` command, and it's all taken care. If you edit over FTP, make the FTP folder as a drive or folder, and `bzr update` after the commit. [1]: http://doc.bazaar-vcs.org/lates...
Remote Linux server to remote linux server dir copy. How?
|linux|data-transfer|
What is the best way to copy a directory (with sub-dirs and files) from one remote Linux server to another remote Linux server? I have connected to both using SSH client (like Putty). I have root access to both.
I agree that the performance difference seen by the poster is most likely caused by disk latency bringing the JRE into memory. The Just In Time compiler (JIT) would not have an impact on performance of a little application. Java 1.6u10 (<http://download.java.net/jdk6/>) touches the runtime JARs in a background proc...
About two years ago, I made the switch from C# to C++ (after 10 years of writing java). The most useful book for me was Bruce Eckel's _Effective C++_ [[AMZN][1]]. You can also read the book online at [Eckel's website][2]. It's a well-written book--the kind you can read in bed--that's also useful as a keyboard-side refe...
Perl objects are NOT just blessed hashes. They are blessed REFERENCES. They can (and most often are) blessed hash references, but they could just as easily be blessed scalar or array references.
Perl objects are NOT just blessed hashes. They are blessed REFERENCES. They can be (and most often are) blessed hash references, but they could just as easily be blessed scalar or array references.
THere's a queryparam scanner that'll find em for you on RIAForge: http://qpscanner.riaforge.org/
You could try putting the following in your constructor after the InitiliseComponent call. SetStyle(ControlStyles::OptimizedBoubleBuffer | ControlStyles::UserPaint | ControlStyles::AllDrawingInWmPaint} , true);
You could try putting the following in your constructor after the InitiliseComponent call. SetStyle(ControlStyles::OptimizedBoubleBuffer | ControlStyles::UserPaint | ControlStyles::AllDrawingInWmPaint} , true); EDIT: If you're giving this a go, if you can, remove your own double bufferi...
Something as simple as RewriteRule ^/[^/]+/([^/]*)/?$ /$2 [R] Perhaps would do it? That simple redirects /foo/bar/ to /bar
Something as simple as RewriteRule ^/[^/]+/([^/]+)/?$ /$2 [R] Perhaps would do it? That simple redirects /foo/bar/ to /bar
If it is all one protocol being handled then a switch/case statement may be your best bet. However you should break all the individual message handlers into their own functions. If your switch statement contains any code to actually handle the messages than you would be better off breaking them out. If it is han...
It is generally a case of just going through one by one and converting them. I don't know of any automated means, The docs - http://trac.lighttpd.net/trac/wiki/Docs%3AModRewrite - has the regexes availble, and some examples. if there are any particularly problematical items, I'd edit the question to show them, a...
The main gotcha I see is that you're not handling any errors: .login() and .sendmail() both have documented exceptions that they can throw, and it seems like .connect() must have some way to indicate that it was unable to connect - probably an exception thrown by the underlying socket code.
Spreadsheet::WriteExcel::Chart You might need something like strawberry or vanilla perl to get this to compile. Or ppm might have the module. Tutorial link: http://search.cpan.org/dist/Spreadsheet-WriteExcel/charts/charts.pod
Paths in master pages
I've used reflection in C# when there was some internal or private method in the framework or a third party library that I wanted to access. (Disclaimer: It's not necessarily a best-practice because private and internal methods may be changed in later versions. But it worked for what I needed.)
After a bit of research we came up with the following list of headers that seemed to cover most browsers: - Expires: 0 - Cache-Control: no-cache, no-store - Pragma: no-cache In ASP.NET we added these using the following snippet: Response.AddHeader("Expires", "0"); Response.AddHeader("Cache-Con...
After a bit of research we came up with the following list of headers that seemed to cover most browsers: - Expires: 0 - Cache-Control: no-cache, no-store - Pragma: no-cache In ASP.NET we added these using the following snippet: Response.ClearHeaders(); Response.AppendHeader("Cache-Control",...
After a bit of research we came up with the following list of headers that seemed to cover most browsers: - [Expires](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21): Mon, 26 Jul 1997 05:00:00 GMT - [Cache-Control](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9): [no-cache](http...
Well, in statically-typed languages, you'd want to use reflection any time you need to do something "dynamic". It comes in handy for tooling purposes (scanning the members of an object). In Java it's used in JMX and dynamic proxies quite a bit. And there are tons of one-off cases where it's really the only way to go...
Robert Walker did a great job of describing [how to send the request][1]. You can read more about [Mozilla's xmlhttprequest here][2]. I would just add that the response would be found (using Robert's code) using xmlhttp.responseText You didn't indicate exactly what the data was, although you mentioned wan...
Robert Walker did a great job of describing [how to send the request][1]. You can read more about [Mozilla's xmlhttprequest here][2]. <strike>I would just add that the response would be found (using Robert's code) using xmlhttp.responseText </strike> (*Edit - i didn't read closely enough, thanks Robert*) ...
[Physics for Game Programmers][1] I think is better than [Physics for Game Developers][2]. If you want something thick in your bookshelf (like I do), Eberly's [3D Game Engine Design][3] and Erleben's [Physics-Based Animation][4] can accompany the above. [1]: http://www.amazon.com/Physics-Game-Programmers-Gran...
I guess what you are looking for is Classical Mechanics, which describes motion in one, two, and three dimensions in a generalized manner. I found a good [introductory course on Classical Mechanics from the University of Texas][1]. I do not guarantee that you will be able to understand all the concepts there, but...
Found this code out there on the [tubes][1]: class DnDTabbedPane extends JTabbedPane { private static final int LINEWIDTH = 3; private static final String NAME = "test"; private final GhostGlassPane glassPane = new GhostGlassPane(); private final Rectangle2D lineRect = new Rectangle...