instruction
stringlengths
0
30k
In C#, what is the best way to test if a dataset is empty?
|c#|.net|
I know you can look at the row.count, but are there other ways to tell if a dataset is empty?
I know you can look at the row.count or tables.count, but are there other ways to tell if a dataset is empty?
You can use the WMI query language for that. Take a look at <http://msdn.microsoft.com/en-us/library/aa394592(VS.85).aspx> for examples. The information you are looking for is available e.g. through the property VolumeName of the Win32_LogicalDisk class, <http://msdn.microsoft.com/en-us/library/aa394173(VS.85).aspx> ...
You can do this with the [Microsoft Loopback Adapter][1] which is a driver for a virtual network card. [1]: http://support.microsoft.com/kb/839013
This bat file will give you the drive letter from a drive label: Option Explicit Dim num, args, objWMIService, objItem, colItems set args = WScript.Arguments num = args.Count if num <> 1 then WScript.Echo "Usage: CScript DriveFromLabel.vbs <label>" WScript.Quit 1 ...
Upgrade database from SQL Server 2000 to 2005 -- and rebuild full-text indexes?
|sql-server|full-text-search|recovery|
I'm loading a SQL Server 2000 database into my new SQL Server 2005 instance. As expected, the full-text catalogs don't come with it. How can I rebuild them? Right-clicking my full text catalogs and hitting "rebuild indexes" just hangs for hours and hours without doing anything, so it doesn't appear to be that simple...
Unix has a 'fork' system call which 'splits' the current process into two, and gives you a second process that is identical to the first (modulo the return from the fork call). Since the address space of the new process is already up and running this is should be cheaper than calling 'CreateProcess' in Windows and hav...
* quirksmode.org has an [overview of various methods][1]. * There's a related SO question: ["In HTML, how to word-break on a dash?"][2] * In browsers that support it, [`word-wrap: break-word`][3] might give the desired effect as well. [1]: http://www.quirksmode.org/oddsandends/wbr.html [2]: http://stackover...
I find that the .NET event model is such that I'll often be raising an event on one thread and listening for it on another thread. I was wondering what the cleanest way to marshal an event from a background thread onto my UI thread is. Currently I use code like this: delegate void CoolObject_CoolEventCallbac...
I find that the .NET event model is such that I'll often be raising an event on one thread and listening for it on another thread. I was wondering what the cleanest way to marshal an event from a background thread onto my UI thread is. Based on the community suggestions, I've used this: // earlier in the cod...
PowerShell - How do I pass string parameters correctly?
|string|powershell|parameters|arguments|
Is there documentation or an article on the rules for passing strings into PowerShell functions? I just trying to do some string concatenation/formatting, but it's putting all the parameters into the first placeholder. **Code** function CreateAppPoolScript([string]$AppPoolName, [string]$AppPoolUser, [string]$...
I'm not a database expert, and I do not speak from experience. However: [MyISAM tables use table-level locking][1]. Based on your traffic estimates, you have close to 200 writes per second. With MyISAM, *only one of these could be in progress at any time*. You have to make sure that your hardware can keep up with th...
I thought most of the virus scanners nowadays use [*sandbox techniques*][1] to check for "bad" behavior. Therefore the polymorphic virusses will also be detected. of course these detection techniques are also known to virus creators, and can easily be bypassed using a bunch of random, unharmfull, code executions bef...
There is another place where the TNS location is stored: If you're using Windows, open <code>regedit</code> and navigate to <code>My HKEY Local Machine/Software/ORACLE/KEY_OraClient10_home1</code> where <code>KEY_OraClient10_home1</code> is your Oracle home. If there is a string entry called <code>TNS_ADMIN</code>, the...
Perhaps you could use an XSL transformation to convert the XSD into SQL table definitions. Likewise, I can't find any prior examples of this, but I'd have thought it would be possible. I'd imagine a generic XSLT for XSD->SQL, once written, could be applied to any such scenario (and would be cross-platform too). Perh...
Note that djvu is an image compression format (optimized to compress 'pictures of text', typically the results of scanning). As such, you won't be able to search for text, except in the metadata -this is what the link sent by cdleary refers to-, *or* if you first use OCR on the document to convert it into text. The ...
WP-Syntax uses GeSHi to do the highlighting, the WordPress Syntax Highlighter uses the [Javascript SyntaxHighlighter][1] [1]: http://code.google.com/p/syntaxhighlighter/wiki/Overview
The "Official" Java API for this is now JAXB - Java API for XML Binding. The reference implementation lives at [https://jaxb.dev.java.net/][1] [1]: https://jaxb.dev.java.net/
B.name is a class attribute, not an instance attribute. It shows up in B.\__dict__, but not in b = B(); b.\__dict__. The distinction is obscured somewhat because when you access an attribute on an instance, the class dict is a fallback. So in the above example, b.name will give you the value of B.name.
I believe that os.system just invokes whatever command shell is configured for the user, so I don't think you can do it in a platform independent way. My command shell could be anything from bash, emacs, ruby, or even quake3. Some of these programs aren't expecting the kind of arguments you are passing to them and ev...
Get a list of current windows, and give one of them focus, in .Net
|.net|windows|
Without resorting to PInvoke, is there a way in .net to find out what windows are open? This is slightly different than asking what applications are running in memory. For example, Firefox could be running, but could be more than one window. Basically, I just want to be privy to the same information that the taskbar...
This book may prove useful: http://www.semantics.org/cpp_gotchas/
For an embedded database, you can use [SQL Server Compact Edition][1]. Unlike SQL Server Express, it is *not* compatible with the LINQ to SQL designer, but it is fully compatible with the command-line SQLMetal. It has a few advantages over SQL Express, like to ability to use embedded or run from a file. Microsoft ha...
[This web page by Scott Wheeler][1] covers some of the main C++ pitfalls. [1]: http://developer.kde.org/~wheeler/cpp-pitfalls.html
I'd look into [Windows Distributed File System][1]. It should be supported by both Windows Server 2003 & 2008. [1]: http://www.microsoft.com/windowsserver2003/techinfo/overview/dfs.mspx
G'day, I assume that you've done your bind using INADDR_ANY to specify the address. If this is the case, then the semantics of INADDR_ANY is such that a UDP socket is created on the port specified on all of your interfaces. The socket is going to get all packets sent to all interfaces on the port specified. Wh...
G'day, I assume that you've done your bind using INADDR_ANY to specify the address. If this is the case, then the semantics of INADDR_ANY is such that a UDP socket is created on the port specified on all of your interfaces. The socket is going to get all packets sent to all interfaces on the port specified. Wh...
@Martin >> VB6 had a "With/End With" statement that worked "like" the Using() statement in C#.NET. And of course, the less global things you have, the better for you. With/End With does not working like the Using statement, it doesn't "Dispose" at the end of the statement. With/End With works in VB 6 just lik...
[DrJava][1] is your best bet. It also has an [Eclipse plugin][2] to use the interactions pane like GroovyConsole. [1]: http://www.drjava.org/ [2]: http://www.drjava.org/eclipse.shtml
The question also arises how to get the data into the BLOB. You can put the data in an INSERT statement, as the PHP example shows (although you should use [mysql_real_escape_string][2] instead of addslashes). If the file exists on the database server, you can also use MySQL's [LOAD_FILE][1] [1]: http://dev.mysql...
Parallelisation aside, you don't want to be calculating sqrt(Until) on every iteration. You also can assume multiples of 2, 3 and 5 and only calculate for N%6 in {1,5} or N%30 in {1,7,11,13,17,19,23,29}. You should be able to parallelize the factoring algorithm quite easily, since the Nth stage only depends on the s...
If its only for word processing, then perhaps [DocBook](http://en.wikipedia.org/wiki/DocBook) might be a little lighter than ODF? However, the wiki entry states: > DocBook is a semantic markup language for technical documentation. It was originally intended for writing technical documents related to computer hard...
For organization, use namespaces as already stated. For global data I like to use the [singleton][1] pattern because it helps with the problem of the unknown initialization order of static objects. In other words, if you use the object as a singleton it is guaranteed to be initialized when its used. Also be su...
2 options spring to mind. 1 is using generics: abstract class Vehicle<TAxle> where TAxle : Axle { public List<TAxle> Axles; } The second uses shadowing - and this assumes you have properties: abstract class Vehicle { public IList<Axle> Axles { get; set; } } class Motorc...
There was a good blog post on the subject @ [coding horror][1] Personally I try to keep its use to a minimum, I have found it hurts readability. [1]: http://www.codinghorror.com/blog/archives/001136.html
There was a good discussion on this @ [Coding Horror][1] Personally I try to keep its use to a minimum, I have found it hurts readability especially when assigning a variable from a method call. [1]: http://www.codinghorror.com/blog/archives/001136.html
Sockets in Pascal
|sockets|networking|pascal|
How do you use network sockets in Pascal?
Here's an example taken from http://www.bastisoft.de/pascal/pasinet.html program daytime; { Simple client program } uses sockets, inetaux, myerror; const RemotePort : Word = 13; var Sock : LongInt; sAddr : TInetSockAddr; sin, so...
Zeroconf and other discovery protocols are similarly referred to as the greatest thing since sliced bread; it's just that the flavor keeps changing.
@Chris > Something like: Dim myArray(10) as String > Would give you an array of 10 String references (each pointing to Nothing). VB is [0-indexed in array declarations][1], so you'd actually have 11 elements in that array. It's a common mistake when translating from C languages. As for the question...
>Are you executing the programs directly or going through the shell? If you always launch an external program by giving the full path name to the executable and leaving the shell out of the equation, then you aren't really susceptible to any kind of command line injection. **@Curt Hagenlocher** The backtick can kill...
Can someone explain __all__ in Python?
|python|
Programatically determine how many Comments a blog post has
|rss|comments|
What is the most efficient way to determine how many comments a particular blog post has? We want to store the data for a new web app. We have a list of permalink URl's as well as the RSS feeds.
If the blog is controlled by you, a "Select count(commentid) FROM comments WHERE postID = 2" will possibly the best thing. If you only have the URL but still it's your blog/db, you need to create a subquery "WHERE postID = (SELECT whatever FROM posts WHERE permalink = url)" or whatever your way to join the comments to ...
A jQuery object is a set of elements. In your case, a set of one element. This differs from certain other libraries, which wrap single elements and provide alternate syntax for selectors that return multiple matches. *[Aaron W][1] and [VolkerK][2] already explained how to access the first (index 0) element in the s...
@Tim Depending on the licensing you might be able to use the TUN/TAP driver that is part of OpenVPN, see [here](http://www.varsanofiev.com/inside/using_tuntap_under_windows.htm) for details.
In addition to the answer of Rob Walker: Nowadys you have things like the Native POSIX Thread Library - if you want. But for a long time the only way to "delegate" the work in the unix world was to use fork() (and it's still prefered in many,many circumstances). e.g. some kind of socket server <pre>socket_accept() ...
Is it worth learning to use MSBuild?
|.net|msbuild|
I simply wondered whether people thought it was worth learning to use the MSBuild syntax in order to customise the build process for a .net project, or whether it is really not worth it given the ease with which one can build a project using visual studio. I am thinking in terms of nightly builds, etc., but then co...
Off-the-Shelf Hex Dump Code
|hexdump|c++|logging|
I work a lot with network and serial communications software, so it is often necessary to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there som...
I work a lot with network and serial communications software, so it is often necessary to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there som...
|hexdump|c++|logging|hex|
I work a lot with network and serial communications software, so it is often necessary to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code for C++ out there som...
|c++|logging|hex|hexdump|
I work a lot with network and serial communications software, so it is often necessary for me to have code to display or log hex dumps of data packets. Every time I do this, I write yet another hex-dump routine from scratch. I'm about to do so again, but figured I'd ask here: Is there any good free hex dump code f...
application/octet-stream You can stream the contents of a .eml file to a browser with this content type and .mht as the extension, and the email will be rendered similar to the way it is rendered in an email client.
I like DocBook, but it doesn't really fit. It strives to be presentation-independent, the intention being that you would use XSLT to render it to a presentation format. In a word processor, the user is editing presentation along with the content. For example, the user doesn't want to mark a "keyword", necessarily, t...
What is the Difference Between Mercurial and Git?
|git|comparison|mercurial|version-control|
I've been using git for some time now on Windows (with msysGit) and I like the idea of distributed source control. Just recently I've been looking at Mercurial (hg) and it looks interesting. However, I can't wrap my head around the differences between hg and git. Has anyone made a side-by-side comparison between git...
I know I'm probably stating the obvious, but don't forget that the quality of the development team and their familiarity with the technology will have a major impact on your ability to deliver. If you have a strong team, then it's probably not an issue if they're familiar. But if you have people who are more 9 to 5...
As others have said SQL 2008 comes with a Filestream type that allows you to store a filename or identifier as a pointer in the db and automatically stores the image on your filesystem which is a great scenario. If you're on an older database, then I'd say that if you're storing it as blob data, then you're really n...
Refactoring is inevitable on larger codebases and the lack of static typing makes this much harder in python than in statically typed languages.
Process ID in Java
|java|pid|
How do I get the id of my Java process? I know there are several platform-dependent hacks, but I'm after a generic solution.
Have you tried manually modifying the XSL in order to generate HTML which embedds your audio file? I don't think there is a way to do this using the InfoPath Designer, but if it ends up in the XSL; it may just get passed through to the web enabled form.
I'm currently in the process of migrating from SVN to a DVCS (while blogging about my findings, my first real blogging effort...), and I've done a bit of research (=googling). As far as I can see you can do most of the things with both packages. It seems like git has a few more or better implemented advanced features, ...
The other suggestions are good if you have "SQL only". However I suggest, that - **if possible** - you calculate the date in your program and insert it as string in the SQL query. At least for for big tables (i.e. several million rows, maybe combined with joins) that will give you a considerable speed improvement...
try beanshell. its a scripting wrapper over java. http://www.beanshell.org/
FYI, I continued to research and answered my own question. From: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=2235413&SiteID=17 I just altered my report's text box to: "=Fields!Addr1.Value + VbCrLf + Fields!Addr2.Value + VbCrLf + Fields!Addr3.Value"
Some must have C++ books that will help you avoid common C++ pitfalls: [Effective C++][1] [More Effective C++][2] [Effective STL][3] The Effective STL book explains the vector of bools issue :) [1]: http://www.amazon.com/Effective-Specific-Addison-Wesley-Professional-Computing/dp/0321334876/ref=pd_bbs_...
> And is there a way to populate the table with a list of key->value pairs without individually calling an add method on the object for each pair? One problem with your question is that you don't mention what what form your data is in to begin with. If your list of pairs happened to be a list of Map.Entry objects it...
*Info*: Ajax Navigation is a [regular feature][1] of the upcoming IE8. [1]: http://blogs.msdn.com/ie/archive/2008/07/14/ie8-ajax-navigation.aspx
@[wvdschel][1]: Don't create separate partitions for each user. Unused space on each partition is wasted. Instead create one partition for all users. Use `quota` if necessary to limit each user's space. It's much more flexible than partitioning or LVM. OTOH, one huge partition is usually a bit slower, dependin...
I'm not aware of anyone who keeps track of this publicly on a regular basis (unlike Adobe who pushes it every chance they get). The closest that I could come was [this article][1] from last November. Based upon his site, this data could be skewed a bit, but I think we fairly similar numbers as well. [1]: http:...
Did you know 1TB can easily take up to half an hour to `fsck`? Workstations usually crash and reboot more often than servers, so that can get quite annoying. Do you really need all that space?
I have been using Python more and more, and I keep seeing the variable `__all__` set in different `__init__.py` files. Can someone explain what this does?
The important thing to remember here is that Ruby methods can be (un)defined at any point, so to intelligently resolve the ambiguity, every assignment would need to run code to check whether there is a method with the assigned-to name at the time of assignment.
Your users will not be able to connect to the NTLM site directly without getting an NTLM challenge. I would write what would effectively be a proxy to the NTLM site; i.e your server-side code will have credentials to connect to the NTLM site, and it passes through the requests from your users. As you mention it's ...
> General programming translates terribly to GPUs. GPUs are dedicated to performing fairly simple tasks on streams of data at a massive rate, with massive parallelism. They do not deal well with the rich data and control structures of general programming, and there's no point trying to shoehorn that into them. This ...
I am pretty much hook to: - The Java Posse - Software Engineering Radio
When you [Process.Start][1] a new process, supply the parameters in its Parameters argument instead of building the whole command line yourself. Haven't got time for a proper test, but I think that should help guard it to some level. Will test this out tomorrow. **EDIT:** Ah, someone beat me to it again. But...
I'm sure there is an easier way, but you could loop through the sysobjects table in the database and grant permissions to any user table objects that exist. You could then run that multiple times whenever new tables are added.